-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { BaraReactText, TextPressEventFilter } from './event' | ||
import { kindOf, nameOf } from '../../functions/common' | ||
|
||
export const nameOfText = (name: string) => (triggeringEvent: BaraReactText): boolean => | ||
name ? name === triggeringEvent.name : true | ||
export const nameOfText = nameOf | ||
|
||
export const kindOfText = kindOf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
import { TextPressEventFilter } from './event' | ||
import { | ||
ActionPipe, | ||
BaraEventPayload, | ||
ConditionPipe, | ||
createPipe, | ||
useAction, | ||
useCondition, | ||
useEvent, | ||
useTrigger, | ||
} from 'bara' | ||
|
||
import { BaraReactText, useTextLongPressEvent, useTextPressEvent } from './event' | ||
import { TextPressCallback, useTextPressTrigger } from './trigger' | ||
|
||
export function useTextPress( | ||
eventFilter: TextPressEventFilter, | ||
callback: TextPressCallback, | ||
) { | ||
return useTextPressTrigger(eventFilter, callback) | ||
export const whenTextPress = ( | ||
...conditions: Array<ConditionPipe<BaraReactText>> | ||
) => (...actions: Array<ActionPipe<BaraReactText>>) => { | ||
const piper = ( | ||
data: BaraReactText, | ||
payload: BaraEventPayload<BaraReactText>, | ||
) => { | ||
createPipe(data, payload)(...(conditions as any))(...actions) | ||
} | ||
useTrigger<BaraReactText>(() => { | ||
const event = useTextPressEvent() | ||
const action = useAction(piper) | ||
return { event, action } | ||
}) | ||
} | ||
|
||
export const whenTextLongPress = ( | ||
...conditions: Array<ConditionPipe<BaraReactText>> | ||
) => (...actions: Array<ActionPipe<BaraReactText>>) => { | ||
const piper = ( | ||
data: BaraReactText, | ||
payload: BaraEventPayload<BaraReactText>, | ||
) => { | ||
createPipe(data, payload)(...(conditions as any))(...actions) | ||
} | ||
useTrigger<BaraReactText>(() => { | ||
const event = useTextLongPressEvent() | ||
const action = useAction(piper) | ||
return { event, action } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters