Giter VIP home page Giter VIP logo

deferred's People

Contributors

akitchen avatar cbguder avatar christian-smith avatar jeffh avatar kseebaldt avatar orta avatar raphweiner avatar tanglisha avatar thedavidharris avatar toddlee avatar tomquist avatar wileykestner avatar zacclark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deferred's Issues

Questions...

Hi guys.... just inherited some code with this pod.

Is this pod still being maintained?
Can we have a tag for the latest code from 2019?
Why was a tag never created?

Thanks for all your support.

EXC_BAD_ACCESS adding to KSPromise callbacks

I'm seeing a bunch of these crashes at various places throughout our app:

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
Thread : Crashed: com.apple.main-thread
0  CoreFoundation                 0x18301a698 -[__NSArrayM insertObject:atIndex:] + 504
1  my-app                         0x10028f870 -[KSPromise then:error:] (KSPromise.m:124)

The offending line, KSPromise.m:124, reads [self.callbacks addObject:callbacks];. Seems like self.callbacks has disappeared by the time we call -[KSPromise then:error:]. I suspect our misusage of the library might be at fault. Any idea of what usage pattern might cause something like this? Perhaps multiple attempts at resolution? We do have this plugged into an asynchronous API that is known to call its own callbacks more than once, so I could see how this could be the case.

Running KSDeferred 0.3.0 via CocoaPods.

Strange issue on pod update

The platform of the target `Pods` (tvOS 9.0) is not compatible with `KSDeferred (0.3.0)`, which does not support `tvos`.

But it seems to be included in the podspec.

Joins could not be atomic

We use joins where we are collecting a list of objects being fetched. If any fetch fails, the aggregate operation is failed and our list ends up empty, but it would be better to get the list without objects that fail.

It would be good if a join could return the good and the bad. So, maybe something like:

typedef id(^joinPromiseCallback)(NSArray *values, NSArray *errors));

  • (KSPromise *)eventually:(joinPromiseCallback)callback

resolve nil joined promise crashes

If you resolve a a KSDefer with nil and a related KSPromise is joined, then the app crashes. If the promise is not joined then it appears to work fine, but when joining promises either resolving or rejecting a defer with nil will result in an attempt to add nil to an NSMutableArray, which throws an exception.

from KSPromise.m:

  • (void)joinedPromiseFulfilled:(KSPromise *)promise {
    BOOL fulfilled = YES;
    NSMutableArray *errors = [NSMutableArray array];
    NSMutableArray *values = [NSMutableArray array];
    for (KSPromise *joinedPromise in self.parentPromises) {
    fulfilled = fulfilled && joinedPromise.completed;
    if (joinedPromise.rejected) {
    !! [errors addObject:joinedPromise.error];
    } else if (joinedPromise.fulfilled) {
    !! [values addObject:joinedPromise.value];
    }
    }

0.2.0 is too old

Hi! I've been using KSDeferred for a while (thanks!), but I have to point Cocoapods to master. Would it be possible to tag a new version?

Thank you so much for the effort put in this.

ARC Restrictions

Maybe I'm missing something, but when I try to compile for iOS deployment target 6.1 using ARC I get these errors:
"ARC forbids explicit message send of 'release'"
"'release' is unavailable: not available in automatic reference count mode"

sendAsynchronousRequest: sometimes responds with NSData on error.

In a project I'm working on, a 401 (Unauthorized) status code is returned, along with some JSON message from the server for the reasoning (eg - too many failed login attempts, etc.).

So while an error is given, the NSData argument in the completion handler of -[sendAsynchronousRequest:queue:completionHandler:] is filled out, but using KSNetworkClient, there is no way to get this.

I know the code to fix this, but I can't seem to modify the NSURLProtocol correctly to make an example that would fail -- short of exercising with http://

The new method body of the KSNetworkClient would be like this:

- (KSPromise *)sendAsynchronousRequest:(NSURLRequest *)request queue:(NSOperationQueue *)queue {
    KSDeferred *deferred = [KSDeferred defer];
    [NSURLConnection sendAsynchronousRequest:request
                                       queue:queue
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
        if (error) {
            if (data) {
                NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo];
                userInfo[KSResponseDataKey] = data;
                error = [NSError errorWithDomain:error.domain
                                            code:error.code
                                        userInfo:userInfo];
            }
            [deferred rejectWithError:error];
        } else {
            [deferred resolveWithValue:[KSNetworkResponse networkResponseWithURLResponse:response
                                                                                    data:data]];
        }
    }];
    return deferred.promise;
}

Which simply adds the NSData parameter to the userInfo key of the error if available.

I drove it out by hitting a service with basic auth (sadly).

fit(@"does a live http auth connection", ^{
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://demo.socialcast.com/api/authentication.json"]];
    KSPromise *promise = [client sendAsynchronousRequest:request queue:queue];
    dispatch_semaphore_t sema = dispatch_semaphore_create(0);
    [promise then:^id(id value) {
        dispatch_semaphore_signal(sema);
        return value;
    } error:^id(NSError *error) {
        dispatch_semaphore_signal(sema);
        return error;
    }];
    dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
    NSString *data = [[NSString alloc] initWithData:promise.error.userInfo[KSResponseDataKey] encoding:NSUTF8StringEncoding];
    data should equal(@"true");
});

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.