How to use processStrategy with Object schema

297 views Asked by At

How to use normalizr's schema.Object with processStrategy

It looks like Object doesn't have processStrategy option like Entity

const deepNestedObj = new schema.Object({}, { 
  processStrategy: (value) => {
    someExternalService(value);
    return value;
  }
})
const schema = new schema.Entity(...)

I would like to do something like this

1

There are 1 answers

0
Paul Armstrong On BEST ANSWER

Object does not use processStrategy. See options available in the docs.

If your object has a unique ID, the recommendation is to use schema.Entity and its processing strategy.

Alternatively, since it looks like maybe deepNestedObj is something that's internal to your schema.Entity, you can just use the processStrategy option available on the Entity.