Created
April 17, 2021 20:11
-
-
Save havremunken/1825b2cc016246c888f2318b5dd681ba to your computer and use it in GitHub Desktop.
Controller for ember-concurrency issue #422
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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