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

Projects
None yet
1 participant

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 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 join this conversation on GitHub. Already have an account? Sign in to comment