Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Create RxJS Streams in the Vue.js Subscriptions Function

    5.5.12 - 6.4.0

    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.



    Become a Member to view code

    You must be a Pro 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
    orLog In




    Instructor: 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.

    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.

    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...