Skip to content

Commit

Permalink
Merge 209e268 into f44cbd7
Browse files Browse the repository at this point in the history
  • Loading branch information
NaridaL committed Nov 3, 2019
2 parents f44cbd7 + 209e268 commit 077a769
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import primitive from "./types/primitive"
import primitive from "./types/primitive";

/**
* In the event that a property needs to be deserialized, but not serialized, you can use the SKIP symbol to omit the property. This has to be used with the custom serializer.
* If you want to skip serialization or deserialization, you can use SKIP.
*
* @example
* // Skipping serialization with custom serializer.
*
* var schema = _.createSimpleSchema({
* a: _.custom(
* function(v) {
Expand All @@ -16,7 +18,28 @@ import primitive from "./types/primitive"
* });
* t.deepEqual(_.serialize(s, { a: 4 }), { });
* t.deepEqual(_.deserialize(s, { a: 4 }), { a: 4 });
*
* @example
* // Skipping deserialization with computed mobx property.
*
* class TodoState {
* // Todo.category is @serializable(reference(...))
* @serializable(list(object(Todo)))
* @observable
* todos: Todo[]
*
* // we want to serialize the categories, so that the references in
* // this.todos can be resolved, but we don't want to set this property
* @serializable(
* list(object(TodoCategory),
* { afterDeserialize: callback => callback(undefined, SKIP) }))
* @computed
* get categories() {
* return this.todos.map(todo => todo.category)
* }
* }
*/
export var SKIP = typeof Symbol !== "undefined" ? Symbol("SKIP") : { SKIP: true }
export var SKIP =
typeof Symbol !== "undefined" ? Symbol("SKIP") : { SKIP: true };

export var _defaultPrimitiveProp = primitive()
export var _defaultPrimitiveProp = primitive();

0 comments on commit 077a769

Please sign in to comment.