-
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.
feat(TouchableOpacity): change the way hook take params
this making it easier to do functional programming
- Loading branch information
Showing
5 changed files
with
91 additions
and
24 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
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,5 @@ | ||
import { BaraReactTouchableOpacity, TouchableOpacityEventFilter } from './event' | ||
|
||
export const nameOfTouchableOpacity = (name: string) => ( | ||
triggeringEvent: BaraReactTouchableOpacity, | ||
): boolean => (name ? name === triggeringEvent.name : true) | ||
|
||
export const classOfTouchableOpacity = (className: string) => ( | ||
triggeringEvent: BaraReactTouchableOpacity, | ||
): boolean => (className ? className === triggeringEvent.className : true) | ||
export const nameOfTouchableOpacity = (checkName: string) => ({ | ||
name, | ||
}: BaraReactTouchableOpacity) => checkName === name |
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,12 +1,34 @@ | ||
import { TouchableOpacityEventFilter } from './event' | ||
import { | ||
TouchableOpacityPressCallback, | ||
useTouchableOpacityPressTrigger, | ||
} from './trigger' | ||
ActionPipeFunction, | ||
BaraEventPayload, | ||
ConditionPipe, | ||
createPipe, | ||
useAction, | ||
useCondition, | ||
useEvent, | ||
useTrigger, | ||
} from 'bara' | ||
|
||
export function useTouchableOpacityPress( | ||
eventFilter: TouchableOpacityEventFilter, | ||
callback: TouchableOpacityPressCallback, | ||
) { | ||
return useTouchableOpacityPressTrigger(eventFilter, callback) | ||
import { | ||
BaraReactTouchableOpacity, | ||
TouchableOpacityEventFilter, | ||
useTouchableOpacityPressEvent, | ||
} from './event' | ||
|
||
export const useTouchableOpacityPress = ( | ||
...conditions: Array<ConditionPipe<BaraReactTouchableOpacity>> | ||
) => (...actions: ActionPipeFunction[]) => { | ||
const piper = ( | ||
data: BaraReactTouchableOpacity, | ||
payload: BaraEventPayload<BaraReactTouchableOpacity>, | ||
) => { | ||
createPipe(data, payload)( | ||
...(conditions as any), | ||
)(...actions) | ||
} | ||
useTrigger<BaraReactTouchableOpacity>(() => { | ||
const event = useTouchableOpacityPressEvent() | ||
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