Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
remove item - tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
philcockfield committed Oct 26, 2023
1 parent 6637bb5 commit 347c670
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function commands(list?: t.LabelListState) {
return api;
},
remove(index) {
if (index === undefined || index < 0) return api;
dispatch({ type: 'List:Remove', payload: { index, tx: slug() } });
return api;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type LabelListEvents<D extends O = O> = t.Lifecycle & {
export type LabelListDispatch = {
select(item: Index | Id, focus?: boolean): LabelListDispatch;
redraw(item?: Index | Id): LabelListDispatch;
remove(index: Index): LabelListDispatch;
remove(index?: Index): LabelListDispatch;
focus(focus?: boolean): LabelListDispatch;
blur(): LabelListDispatch;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default Dev.describe(name, (e) => {
init: {
list(dev: t.DevCtxState<T>) {
const list = TestState.list;
list.events().cmd.remove$.subscribe((e) => {
const events = list.events();
events.cmd.remove$.subscribe((e) => {
local.total = TestState.array.remove(e.index).length;
});
},
Expand Down

0 comments on commit 347c670

Please sign in to comment.