UNPKG

react-native-navigation

Version:

React Native Navigation - truly native navigation for iOS and Android

32 lines (31 loc) 1.02 kB
"use strict"; import { LayoutType } from "./LayoutType.js"; export class LayoutTreeCrawler { constructor(store, optionsProcessor) { this.store = store; this.optionsProcessor = optionsProcessor; this.crawl = this.crawl.bind(this); } crawl(node, commandName) { if (node.type === LayoutType.Component) { this.handleComponent(node); } const componentProps = this.store.getPropsForId(node.id) || undefined; this.optionsProcessor.processOptions(commandName, node.data.options, componentProps); node.children.forEach(value => this.crawl(value, commandName)); } handleComponent(node) { this.assertComponentDataName(node); this.savePropsToStore(node); node.data.passProps = undefined; } savePropsToStore(node) { this.store.setPendingProps(node.id, node.data.passProps); } assertComponentDataName(component) { if (!component.data.name) { throw new Error('Missing component data.name'); } } } //# sourceMappingURL=LayoutTreeCrawler.js.map