@@ -112,6 +112,47 @@ Once some records has been loaded they are also cached in the DataStore, you can
112
112
records = store.getAll('User')
113
113
```
114
114
115
+ ### Hooks
116
+
117
+ Sometime you want to be able to do some custom additional serialization / deserialization.
118
+
119
+ #### By using the adapter
120
+
121
+ ``` js
122
+ const jsonApiAdapter = new JsonApiAdapter ({
123
+ store: store,
124
+ beforeDeserialize : function (mapper , data , opts ) { return data; }
125
+ afterDeserialize : function (mapper , data , opts ) { return data; }
126
+ beforeSerialize : function (mapper , data , opts ) { return data; }
127
+ afterSerialize : function (mapper , data , opts ) { return data; }
128
+ });
129
+ ```
130
+
131
+ #### By using the mapper
132
+
133
+ ``` js
134
+ const UserMapper = store .defineMapper (' User' , {
135
+ beforeDeserialize : function (mapper , data , opts ) { return data; }
136
+ afterDeserialize : function (mapper , data , opts ) { return data; }
137
+ beforeSerialize : function (mapper , data , opts ) { return data; }
138
+ afterSerialize : function (mapper , data , opts ) { return data; }
139
+ });
140
+ ```
141
+
142
+ #### When doing requests
143
+
144
+ ``` js
145
+ store .findAll (' User' , {}, {
146
+ beforeDeserialize : function (mapper , data , opts ) { return data; }
147
+ afterDeserialize : function (mapper , data , opts ) { return data; }
148
+ });
149
+
150
+ store .update (' User' , {}, {
151
+ beforeSerialize : function (mapper , data , opts ) { return data; }
152
+ afterSerialize : function (mapper , data , opts ) { return data; }
153
+ });
154
+ ```
155
+
115
156
116
157
### Get JSONApi Meta
117
158
0 commit comments