Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ember-concurrency #79

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/controllers/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ import { service } from '@ember/service';
import type SessionService from 'ember-simple-auth/addon/services/session';
import type EmberNotify from 'ember-notify';
import { tracked } from '@glimmer/tracking';
import { restartableTask, timeout } from 'ember-concurrency';
import type { Task } from 'ember-concurrency';

type MyTaskType = Task<void, []>;

export class ApplicationController extends Controller {
@service session: SessionService;
@service notify: EmberNotify;
@tracked showModal = true;

closeModal = () => {
closeModalTask: MyTaskType = restartableTask(async () => {
await this.notify.info(
`You trying to close modal, let's debounce it for 300ms`
);
await timeout(300);
this.showModal = false;
});

closeModal = () => {
this.closeModalTask.perform();
};

constructor(...args: ConstructorParameters<typeof Controller>) {
Expand Down
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import refBucketTransform from 'ember-ref-bucket/lib/ref-transform.js';
import { babelHotReloadPlugin } from './plugins/hot-reload';
import { removeLegacyLayout } from './plugins/remove-legacy-layout';
import { dropImportSync } from './plugins/drop-import-sync';
import emberConcurrencyTransform from 'ember-concurrency/lib/babel-plugin-transform-ember-concurrency-async-tasks';
export default defineConfig(({ mode }) => {
const isProd = mode === 'production';
const isDev = mode === 'development';
Expand Down Expand Up @@ -424,6 +425,7 @@ function defaultBabelPlugins(isProd: boolean) {
},
],
templateCompilationPlugin(isProd),
emberConcurrencyTransform,
];
}

Expand Down
Loading