getData
Retrieves a record.
function(params)
Returns a promise that resolves to the instance data for particular parameters.
The following shows how constructor calls getData
and what it does with the response:
connection.getData({id: 1}).then(function(instanceData){
connection.hydrateInstance(instanceData);
});
Parameters
- params
{Object}
:A object that represents the set of data needed to be loaded.
Returns
{Promise<Object>}
:
A promise that resolves to the properties of a record.
Use
Extensions like data/url implement getData
but implementing it yourself can be as simple as:
var behavior = connect([],{
getData: function(params){
return new Promise(function(resolve, reject){
$.get("/api/todo",params).then(resolve, reject)
});
}
})