Skip to content

Instantly share code, notes, and snippets.

@havremunken
Created April 17, 2021 20:11
Show Gist options
  • Save havremunken/1825b2cc016246c888f2318b5dd681ba to your computer and use it in GitHub Desktop.
Save havremunken/1825b2cc016246c888f2318b5dd681ba to your computer and use it in GitHub Desktop.
Controller for ember-concurrency issue #422
import Controller from '@ember/controller';
import { restartableTask, timeout } from 'ember-concurrency';
import { isBlank } from '@ember/utils';
const DEBOUNCE_MS = 250;
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@restartableTask *updateFilter(term) {
if (isBlank(term)) {
//yield timeout(1);
//yield Promise.resolve();
console.log('Early return');
return term;
}
// Pause for debounce
yield timeout(DEBOUNCE_MS);
return term;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment