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:

  • Documents in the store
  • RESTSerializer
+3
websocket ember-data data-munging


source to share


No one has answered this question yet

Check out similar questions:

944
What are Long-Polling, Websockets, Server-Sent Events (SSE), and Comet?
755
WebSockets or Server-Sent / EventSource Events
356
Which websocket library to use with Node.js?
291
WebSockets vs HTTP
233
Differences between socket.io and websockets
12
Loading JSON object into Ember data e.g. Including JSON on the page when loading and populating the store
five
Ember.js / Ember Data takes a few minutes to update the hasMany parent after thousands of child records have been created
2
How Ember Data writes instances of stored model data
2
How do I move data into the ember store of a model that has a JSONSerializer in it since it was set to JSONAPISerializer or RESTSerializer in Ember js?
1
find all events with ember data in api route events



All Articles
Loading...
X
Show
Funny
Dev
Pics