Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between different normalization/serialization hooks in ember data?

There are many hooks in ember data v1.0.0-beta.16.1.

Its just hard to understand the purpose of these hooks. To a novice it seems all of them are meant to do the same thing.

I am looking to understand applications of,

A. normalize and normalizeHash

B. serialize

C. normalizePayload

like image 644
Ahmed Abbas Avatar asked Apr 24 '15 09:04

Ahmed Abbas


People also ask

What is normalization in serialization?

normalize is used to modify root object in incoming payload. normalizeHash is used to modify individual object properties in incoming payload. serialize is used to modify the outgoing object being sent to server. normalizedPayload is used to remove extraneous data from incoming payload such as meta data.

What is serializer in Ember?

In Ember Data, serializers format the data sent to and received from the backend store. By default, Ember Data serializes data using the JSON:API format. If your backend uses a different format, Ember Data allows you to customize the serializer or use a different serializer entirely.


1 Answers

The docs explain them pretty well, but here is my take on it:

normalize is used to modify root object in incoming payload.

normalizeHash is used to modify individual object properties in incoming payload.

serialize is used to modify the outgoing object being sent to server.

normalizedPayload is used to remove extraneous data from incoming payload such as meta data.

like image 143
Miguel Mota Avatar answered Oct 25 '22 11:10

Miguel Mota