Skip to content
module@warp-drive/legacy/compat @legacy

Function normalize() ​

ts
function normalize(
   this: Store$1, 
   modelName: string, 
   payload: ObjectValue
): SingleResourceDocument;

Defined in: warp-drive-packages/legacy/src/compat.ts:278

Legacy

normalize converts a json payload into the normalized form expected by Store.push | push using the serializer specified by modelName

WARNING

Generally it would be better to invoke the serializer yourself directly, or write a more specialized normalization utility.

Example

js
socket.on('message', function(message) {
  let modelName = message.model;
  let data = message.data;
  store.push(store.normalize(modelName, data));
});

Parameters ​

this ​

Store$1

modelName ​

string

The name of the model type for this payload

payload ​

ObjectValue

Returns ​

SingleResourceDocument

The normalized payload

Released under the MIT License.