wireload / Ratatosk

Ratatosk is a Cappuccino remote object proxy for RESTful JSON based APIs.
BSD 3-Clause "New" or "Revised" License
38 stars 14 forks source link

New Delegate Methods on WLRemoteLink #1

Closed milestinsley closed 12 years ago

milestinsley commented 12 years ago

I needed this feature for our app and thought it would be a useful addition to the framework.

The need arose when I wanted my session controller to know whenever a Ratatosk persistence action finished or failed.

This update simply lets you set a delegate on the shared WLRemoteLink object i.e.:

[[WLRemoteLink sharedRemoteLink] setDelegate:self];

The delegate will then receive the following messages:

- (void)remoteActionDidFail:(WLRemoteAction)anAction dueToAuthentication:(BOOL)dueToAuthentication

- (void)remoteActionDidFinish:(WLRemoteAction)anAction

aljungberg commented 12 years ago

Looks nice. Wouldn't observing WLRemoteLink's state allow you to see when it's in WLRemoteLinkStateAuthenticationError or WLRemoteLinkStateRequestFailureError?

milestinsley commented 12 years ago

Observing changes to WLRemoteLinks's state was my original thought, but the state won't change on every action.

I specifically needed to know every time an action was finished, even if the state is already WLRemoteLinkStateNormal (and doesn't change).

milestinsley commented 12 years ago

Ok, I understand what you mean now. At first it appeared that observing WLRemoteLinks's state would only trigger when it actually changes state. But I've been playing around with it and as you suggest, the observer does in fact fire whenever the state is set internally, regardless of if it has changed or not.

This is just what I needed! Thanks for your help. I'll close this PR.

aljungberg commented 12 years ago

Actually it might not be a bad pull request either way. I was planning to merge it. :)