Skip to content

Commit

Permalink
feat(utils): add getSignalCollection function
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbutt committed Apr 21, 2022
1 parent 9ae0a98 commit 582b61d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/utils/getSignalCollection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { IBaseEventAction, IBaseSignal, IBaseState } from "../types";

export function getSignalCollection<T>(
length: number,
state: IBaseState<T>[],
action: IBaseEventAction<T>[],
): IBaseSignal<IBaseState<T>, IBaseEventAction<T>>[] {
const signals: IBaseSignal<IBaseState<T>, IBaseEventAction<T>>[] = [];

// eslint-disable-next-line no-plusplus
for (let index = 0; index < length; index++) {
signals.push({ state: state[index], action: action[index] });
}

return signals;
}

export default getSignalCollection;
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./getSignalCollection";

0 comments on commit 582b61d

Please sign in to comment.