Skip to content

Commit

Permalink
Fabric: Universal fromDynamic for std::vector<...>
Browse files Browse the repository at this point in the history
Summary:
Now, if `fromDynamic` is defined for some type, `fromDynamic` for `std::vector` of this type is also will be defined.
We need this for parsing `ImageSources` (a vector of `ImageSource`) type.

Reviewed By: fkgozali

Differential Revision: D8473508

fbshipit-source-id: d8dc8e3a3273f35b76c7132c553130762f768394
  • Loading branch information
shergin authored and facebook-github-bot committed Jun 18, 2018
1 parent d92601b commit 310a285
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ReactCommon/fabric/core/propsConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ inline void fromDynamic(const folly::dynamic &value, int &result) {
}
inline void fromDynamic(const folly::dynamic &value, std::string &result) { result = value.getString(); }

template <typename T>
inline void fromDynamic(const folly::dynamic &value, std::vector<T> &result) {
result.clear();
T itemResult;
for (auto &itemValue : value) {
fromDynamic(itemValue, itemResult);
result.push_back(itemResult);
}
}

template <typename T>
inline T convertRawProp(
const RawProps &rawProps,
Expand Down

0 comments on commit 310a285

Please sign in to comment.