Make the throttle time configurable

This commit is contained in:
Michael Lange
2018-02-12 15:23:35 -08:00
parent 6bf66f9ec8
commit 4dd6972a33

View File

@@ -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;