request action for gaffa
Allows for arbitrary asynchronous messaging via a common action.
npm i gaffa-request
var Request = require('gaffa-request');
Request.providers.push(function(action, name, options, callback){
// if this provider can handle the given name, handle it.
if(name === 'someHandlerName'){
// This could be an ajax request, or local storage, or sockets..
handleRequest(action, options, callback)l
// you MUST return true so that no other handlers will be triggered.
return true;
}
});
gaffa.registerConstructor(Request);
var request = new Request();
request.name.value = 'someHandlerName';
The data to send with the request
The location to store data returned from the request
The location to store errors returned from the request
Whether to mark the target model location as clean.
Abitrarty settings to pass to the request handler
which request handler to use.
The loading state of the request.