Autoplay

    Create RxJS Streams in the Vue.js Subscriptions Function

    John LindquistJohn Lindquist

    While it's possible to use an Object to configure your streams, using a Function gives you much more flexibility to configure streams. This lesson shows how to use the functions to configure and return multiple streams based on the same source.

    vueVue.js
    ^2.0.0
    rxjsRxJS
    ^5.0.0
    javascriptJavaScript
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 00:00 rather than using a subscription's object, it's more common to use a subscription's function. The function returns an object with those streams on it. If I create another interval here and say this is observable interval of one second, then I can create a times two, which is interval and mapped to that value times two.

    00:28 We'll duplicate this line and create a times three, which is the same but times three. Then, I can return an object with both of these on there, so times two and times three and render them both out. Instead of message, we'll render out times two and times three.

    00:50 Hit Save here, and you'll see these will update by twos and threes because we have a function returning an object with multiple streams on it...

    Discuss

    Discuss