Rather than using Components to push streams into other Components, mapPropsStream allows you to create functions that can wrap components to create shareable behaviors across components.
MapPropsStream allows you to create functions that will decorate your component, rather than creating a component itself. I'm going to create an interval here using MapPropsStream.
It has a similar signature to our component fromStream, where it takes a function with a stream of props. We can props, switchMap, and use our props to return an observable.interval every one second. Then, as usual, use our selector here to take the props and the count that's back from our interval and return some props. Spread out the props and take that count.
Now the props will have a count on it. This returns that stream of props. This does not map to a component like before, so we need to invoke it. I'll say counter with interval and invoke it. Interval and then pass in the counter down here. Now I can swap out counter to counter with interval. Save that, and you'll see the prop streaming in every one second, taking that count, and pushing it into the counter.
You must be a Pro Member to view code
Access all courses and lessons, track your progress, gain confidence and expertise.