Remote Collections
A convenient way for managing collections with remote data
Getting started
Extending from Remote Collection
In order to implement each request per operation we need to extend from RemoteCollection
class ProductCollection extends TSCore.Data.RemoteCollection {
public createOperation(operation) {
}
public updateOperation(operation) {
}
public destroyOperation(operation) {
}
}
Events
Remote Collections allow you to implement events that will be emitted when performing an create/update/destroy. They help define business rules for a certain collection. The following are the events supported by TSCore\Collections\RemoteCollection and their order of execution:
| Operation | Name | Can stop operation |
|---|---|---|
| Inserting | beforeCreate | YES |
| Inserting | afterCreate | NO |
| Updating | beforeUpdate | YES |
| Updating | afterUpdate | NO |
| Destroy | beforeDestroy | YES |
| Destroy | afterDestroy | NO |
Example event
var collection = new RemoteCollection('products');
collection.on('create', (evt) => {
console.log(evt.params.item);
// {}
});
Updated less than a minute ago
