Giter Site home page Giter Site logo

Comments (2)

erichoracek avatar erichoracek commented on April 28, 2024 1

Hi @raduraducuโ€”it sounds like you may want something like shareWhileActive. It isn't included as a core operator in ReactiveObjC, but should give you similar behavior. It is available in this gist https://gist.github.com/jaredru/5540a15c5a1bdcc31787.

In the scenario you've described, this will have the behavior of interrupting all subscriptions when an error occurs. However, if a new subscription occurs following the error, the request will be retried.

from reactiveobjc.

raduraducu avatar raduraducu commented on April 28, 2024

I've looked at shareWhileActive and it does solve half of the problem. What I want to achieve is something like this:

    __weak typeof(self) welf = self;
    return [[[[RACSignal zip:@[RACObserve(self, completeResult), RACObserve(self, completing)]]
            flattenMap:^id(RACTuple *value) {
                __strong typeof(welf) swelf = welf;
                BOOL completing = [value.second boolValue];
                if (completing) {
                    return [RACObserve(swelf, completeResult) skip:1];
                }
                else {
                    if (!self.completeResult || [self.completeResult isKindOfClass:NSError.class]) {
                        [self completeAgain];
                        return [RACObserve(swelf, completeResult) skip:1];
                    }
                    else {
                        return RACObserve(swelf, completeResult);
                    }
                }
            }] subscribeOn:[RACScheduler mainThreadScheduler]] take:1];

The setting of completing and completeResult also happens on the same (main) scheduler to take care of synchronization issues. Can this be done more nicely?

from reactiveobjc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.