mobxjs / serializr

Serialize and deserialize complex object graphs to and from JSON and Javascript classes
MIT License
766 stars 52 forks source link

Custom serializers are not passed the context obj in the deserializr #51

Closed alexggordon closed 7 years ago

alexggordon commented 7 years ago

Currently, when using a custom serializer, the custom function does not result in the context being passed to whatever functions are provided to it.

We should change this, so we can allow for deserializer's to receive the context object

custom(
  // serializer, this works
  (jsonVal, done, context) => context.json.otherValue ? jsonVal : someOtherValue,

  // deserializer, context doesn't exist
  (jsonVal, done, context) => { console.log(context) // not here; return jsonVal }
) data;