derbyjs / racer

Realtime model synchronization engine for Node.js
1.18k stars 116 forks source link

In Model#bundle, use new Contexts#toJSON method for consistency with other data bundle properties #293

Closed ericyhwang closed 1 year ago

ericyhwang commented 1 year ago

In Model#bundle today, all object property values except contexts go through a toJSON() to get a serializable form of the values.

For consistency, this changes Model#bundle to use a new Contexts#toJSON as well, for consistency. That just loops over each context and calls the existing Context#toJSON on each.

This doesn't change the final serialized JSON-string representation, as JSON.stringify automatically calls the contexts' #toJSON today. This just pushes those #toJSON calls a bit earlier.