createInstance
Programatically indicate a new instance has been created.
connection.createInstance(props)
If there is no instance in the instanceStore
for props
's id, an instance is hydrated,
added to the store, and then createdData is called with
props
and the hydrated instance's serialized data. createdData
will add this instance to any lists the instance belongs to.
If this instance has already been created, calls
updateInstance with props
.
Parameters
- props
{Object}
:The raw properties of the instance was created.
Returns
{Promise<Instance>}
:
A promise that resolves to the created instance.
Use
With a real-time
connection, call createInstance
when an instance is created that
the connection itself did not make. For instance, the following might listen to
socket.io for when a todo
is created and update the connection
accordingly:
socket.on('todo created', function(todo){
todoConnection.createInstance(todo);
});