Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Some updates #851

Merged
merged 2 commits into from
Aug 11, 2015
Merged

Some updates #851

merged 2 commits into from
Aug 11, 2015

Conversation

xgrommx
Copy link
Contributor

@xgrommx xgrommx commented Aug 11, 2015

Has been fixed a correct finish if a generator has finished. Also has been added a support for an array as an yield. For example we can use this:

Rx.Observable.spawn(function* () {
    return yield [
        Rx.Observable.just(10).delay(2000),
        Rx.Observable.just(40)
    ];
}).subscribe(::console.log);

Instead of:

Rx.Observable.spawn(function* () {
    return [
        yield Rx.Observable.just(10).delay(2000),
        yield Rx.Observable.just(40)
    ];
}).subscribe(::console.log);

According with https://github.com/tj/co#arrays. But this approach doesn't work https://github.com/tj/co#objects

Also has been added a support for a wrapping a generator with a value according with https://github.com/tj/co#var-fn--cowrapfn. An example:

Rx.Observable.wrap(function* (v) {
    return [
        yield Rx.Observable.just(10).delay(2000),
        yield Rx.Observable.just(v)
    ];
})(1000).subscribe(::console.log);

@ghost ghost added the cla-already-signed label Aug 11, 2015
@xgrommx
Copy link
Contributor Author

xgrommx commented Aug 11, 2015

Regarding with this issue #845

mattpodwysocki added a commit that referenced this pull request Aug 11, 2015
@mattpodwysocki mattpodwysocki merged commit e4d7ad4 into Reactive-Extensions:master Aug 11, 2015
@xgrommx
Copy link
Contributor Author

xgrommx commented Aug 11, 2015

@mattpodwysocki Now we can use:

Rx.Observable.wrap(function*(v) {
    return {
        1: {
            3: yield [
                Rx.Observable.just(20).delay(5000), [
                    Rx.Observable.just(30).delay(2000), Rx.Observable.just(40).delay(3000)
                ]
            ]
        },
        2: yield Promise.resolve(v)
    };
})(1000).subscribe(console.log.bind(console));

But I don't understand why this approach doesn't work:

Rx.Observable.wrap(function*(v) {
    return yield {
        1: {
            3: [
                Rx.Observable.just(20).delay(5000), [
                    Rx.Observable.just(30).delay(2000), Rx.Observable.just(40).delay(3000)
                ]
            ]
        },
        2: Promise.resolve(v)
    };
})(1000).subscribe(console.log.bind(console));

I think https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/spawn.js#L82 isn't good an approach because Rx.Observable.concat use incremental to add value. Probably better an approach will be Rx.Observable.forkJoin

This was referenced Aug 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants