Where to find websocket data in Ember Data

I am writing a web socket service for my Ember application. The service will subscribe to the url and receive data. The data will push the models towards Ember Data store

.

The URL scheme does not represent standard RESTful routes; it is not /posts

and /users

, for example, it is something like /inbound

. As soon as I sign up, it will be just a fire of various events.

For each of these routes I subscribed to, I would need to perform a data transfer specific to that route in order to receive the data in the format that Ember Data expects. My question is, where is the best place to do this?

An example of an event object that I will receive:

event: {
  0: "device:add",
  1: {
    device: {
      devPath: "/some/path",
      label: "abc",
      mountPath: "/some/path",
      serial: "abc",
      uuid: "5406-12F6",
      uniqueIdentifier: "f5e30ccd7a3d4678681b580e03d50cc5",
      mounted: false,
      files: [ ],
      ingest: {
        uniqueIdentifier: 123
        someProp: 123,
        anotherProp: 'abc'
      }
    }
  }
}

      

I want the data to be standardized like

device: {
  id: "f5e30ccd7a3d4678681b580e03d50cc5",
  devPath: "/some/path",
  label: "abc",
  mountPath: "/some/path",
  serial: "abc",
  uuid: "5406-12F6",
  mounted: false,
  files: [ ],
  ingestId: 123
},
ingest: {
  id: 123,
  someProp: 123,
  anotherProp: 'abc'
}

      

and then pass that to what will know how to add both the device model and the ingest model to the store. I am just confused about all the abstractions in ember data.

Questions:

  • What method should be passed to this final standardized JSON for adding records to the store? store.push

    ?
  • Where is the appropriate place to start collecting data, i.e. getting event data from an array? Application Serializer extractSingle

    ? pushPayload

    ? Most of the rooting will be non-standard along different routes.
  • Should serializers of every type be used for every key in the data after I have done the initial setup? those. should I have an initial "blob" for the application serializer, which then delegates each key to the serializers for each model?

Literature:

+3


source to share





All Articles