mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
Make the throttle time configurable
This commit is contained in:
@@ -4,13 +4,16 @@ import { task } from 'ember-concurrency';
|
||||
import wait from 'nomad-ui/utils/wait';
|
||||
|
||||
export function watchRecord(modelName) {
|
||||
return task(function*(id) {
|
||||
return task(function*(id, throttle = 2000) {
|
||||
id = get(id, 'id') || id;
|
||||
while (true) {
|
||||
try {
|
||||
yield RSVP.all([
|
||||
this.store.findRecord(modelName, id, { reload: true, adapterOptions: { watch: true } }),
|
||||
wait(2000),
|
||||
this.get('store').findRecord(modelName, id, {
|
||||
reload: true,
|
||||
adapterOptions: { watch: true },
|
||||
}),
|
||||
wait(throttle),
|
||||
]);
|
||||
} catch (e) {
|
||||
yield e;
|
||||
|
||||
Reference in New Issue
Block a user