ember.js - Trigger REST adapter to push records to store -
i have following setup:
- the ember frontend connected websocket server
- the backend pushes records (real-time data) via websocket clients, stringified json
- the client receives data, , must update store new data received
the problem have not know process raw json data make compatible in store. can of course parse json (json.parse
), part of rest adapter doing.
when doing normal rest request, more or less happens that:
server generates reply -> rest adapter converts -> gets pushed store
but now, since not using rest adapter process data (because not request triggered in client side, notification coming server side), not know how trigger normal processing rest adapter performs.
- how can trigger rest adapter programmatically? can pass stringified json coming websockets server?
- is possible hook rest adapter generic websockets callback, thing have stringified json coming websockets server?
this code have (inspired in web2py
)
function connect_websocket() { console.log('connect_websocket > connecting server'); var callback = function(e) { var data = json.parse(e.data); console.log('data received > data=%o', data); // todo; // - process data rest adapter do, , push new / updated records store. // - handle record deletes (how?) }; if(!$.web2py.web2py_websocket('ws://127.0.0.1:8888/realtime/mygroup', callback)) { alert('html5 websocket not supported browser, try google chrome'); } }
i have taken @ embersockets, far understand not offer generic method of updating records in store, specialized way of updating properties in controllers (which requires lot of configuration too).
what looking generic method of triggering ember rest adapter websockets server. there such thing?
Comments
Post a Comment