Skip to content

Commit

Permalink
feat(rdom): add $inputCheckbox, $inputTrigger
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 24, 2021
1 parent b1cf4d8 commit 99c569e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/rdom/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ export const $input = (stream: ISubscriber<string>) => (e: Event) =>
export const $inputNum = (stream: ISubscriber<number>, fallback = 0) => (
e: Event
) => stream.next(maybeParseFloat((<any>e.target).value, fallback));

/**
* HOF DOM event listener to emit a checkbox input's value on given stream.
*
* @param stream
*/
export const $inputCheckbox = (stream: ISubscriber<boolean>) => (e: Event) =>
stream.next((<HTMLInputElement>e.target).checked);

/**
* HOF DOM event listener to emit `true` on given stream when event is
* triggered.
*
* @param stream
*/
export const $inputTrigger = (stream: ISubscriber<boolean>) => () =>
stream.next(true);

0 comments on commit 99c569e

Please sign in to comment.