knockout.meteor icon indicating copy to clipboard operation
knockout.meteor copied to clipboard

Implement reverse synchronization (from Knockout -> Meteor)

Open steveluscher opened this issue 12 years ago • 1 comments

As pointed out in the example, syncing back to the Meteor Collection has to be done manually. A custom mapping was built to update the Meteor Collection when a Knockout Observable changed:

// This custom mapping adds a callback to a todo's "done" observable.
// The callback watches for changes in the "done" property, and syncs
// them back into the Meteor model.
//
// This reveals a weakness in the current implementation of Knockout Meteor;
// syncing from Meteor->Knockout happens automatically, but syncing back
// from Knockout->Meteor has to be configured manually.
//
// This is both good (you probably want to manage when data is synced back
// to the database) and bad (you have to write the reverse sync code), but
// there's probably a way to implement automatic syncing in both directions
// while still offering enough control over what synced and when.
//
// That's your cue to close the loop and send us a pull request!

I welcome your ideas and implementations.

steveluscher avatar May 02 '12 07:05 steveluscher