mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
Add a watchAll computed property macro
This commit is contained in:
@@ -21,14 +21,30 @@ export function watchRecord(modelName) {
|
||||
}
|
||||
|
||||
export function watchRelationship(staticRelationshipName) {
|
||||
return task(function*(model, relationshipName) {
|
||||
return task(function*(model, throttle = 2000) {
|
||||
while (true) {
|
||||
try {
|
||||
yield RSVP.all([
|
||||
this.store
|
||||
.adapterFor(model.get('modelName'))
|
||||
.reloadRelationship(model, staticRelationshipName || relationshipName, true),
|
||||
wait(2000),
|
||||
this.get('store')
|
||||
.adapterFor(model.constructor.modelName)
|
||||
.reloadRelationship(model, staticRelationshipName, true),
|
||||
wait(throttle),
|
||||
]);
|
||||
} catch (e) {
|
||||
yield e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function watchAll(modelName) {
|
||||
return task(function*(throttle = 2000) {
|
||||
while (true) {
|
||||
try {
|
||||
yield RSVP.all([
|
||||
this.get('store').findAll(modelName, { reload: true, adapterOptions: { watch: true } }),
|
||||
wait(throttle),
|
||||
]);
|
||||
} catch (e) {
|
||||
yield e;
|
||||
|
||||
Reference in New Issue
Block a user