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

Proposal: Add cancelUncompleted Actions #41

Closed
why520crazy opened this issue Jun 28, 2022 · 0 comments
Closed

Proposal: Add cancelUncompleted Actions #41

why520crazy opened this issue Jun 28, 2022 · 0 comments

Comments

@why520crazy
Copy link
Member

why520crazy commented Jun 28, 2022

  1. Store add cancelUncompleted method that cancel all uncompleted actions
this.store.cancelUncompleted(); // 取消所有的 Actions
  1. add cancelUncompleted parameter to @Action()
@Injectable()
export class ItemsStore extends Store<ItemsState> {
    constructor() {
        super({
            items: []
        });
    }

    @Action({ cancelCompleted: true }) // 取消当前的 Action
    fetchItems(type: 1 | 2) {
        return of(['Item 1', 'Item 2']).pipe(
            delay(1000),
            tap((data) => {
                this.setState({ items: data });
            })
        );
    }
}

方案1
新增一个 cancelScope: 'self' | 'store' | 'all' | 某个类别

方案2:
cancelUncompleted 支持支持范围字符串: 'none' | 'self' | 'store' | 'list'(初步确定使用)

讨论问题:

  • Store 销毁的时候自动取消当前 Store 所有的 Actions
  • 是否把 Action 默认的 cancelUncompleted 都设置上,这样做风险有点大,如果一个页面同时调用某个 Actions 多次会出问题。
  • 我们要不要取消所有的 Actions ? 感觉好像没有太大的必要,初步可以实现一个版本
  • 如何取消被标记的列表的 Actions?新增一个 category 把相关的 Actions 标记为一类,这样取消的时候一起取消,后期再实现
@why520crazy why520crazy changed the title Proposal: Add cancelCompleted action Proposal: Add cancelCompleted Jun 28, 2022
@why520crazy why520crazy changed the title Proposal: Add cancelCompleted Proposal: Add cancelUncompleted Actions Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant