Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

CouchModel: ability to distinguish an external change (change tracker) from model being created with document, from model being reverted #64

Open
mz2 opened this issue Feb 10, 2013 · 1 comment

Comments

@mz2
Copy link

mz2 commented Feb 10, 2013

It would be great to have separate overloadable public methods similar to -didLoadFromDocument for the three cases of:

  1. model being created with document.
  2. change tracker induced change to a model object.
  3. a failed save of a model object.

Currently all three cases result in -didLoadFromDocument: being sent to the CouchModel object affected. This is because the method -didLoadFromDocument is called by both -initWithDocument: and by -couchDocumentChanged:, which in turn is called by -CouchDocument's -notifyChanged: and the error case in CouchModel's -saveCompleted:

@mz2
Copy link
Author

mz2 commented Feb 10, 2013

Looks like overloading -couchDocumentChanged: in a CouchModel subclass makes it respond to only the cases 2 and 3 noted above. Something on these lines:

  • (void)couchDocumentChanged:(CouchDocument *)doc
    {
    // couchDocumentChanged: not declared as a public method for CouchModel so need to performSelector: it
    if ([super respondsToSelector:@selector(couchDocumentChanged:)])
    [super performSelector:@selector(couchDocumentChanged:) withObject:doc];

    // do stuff in response to a change tracker induced change, or a failed model object save

}

Is there some way to get a response to only a change tracker induced change (isolate cases 2 and 3 from each other)?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant