-
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(View): change hook function params with new Bara API
It's easier to pipe everything inside the hook BREAKING CHANGE: make hook API pipable
- Loading branch information
Showing
5 changed files
with
49 additions
and
23 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,5 +1,5 @@ | ||
import { BaraReactView } from './event' | ||
import { kindOf, nameOf } from '../../functions/common' | ||
|
||
export const nameOfView = (name: string) => ( | ||
triggeringEvent: BaraReactView, | ||
): boolean => (name ? name === triggeringEvent.name : true) | ||
export const nameOfView = nameOf | ||
|
||
export const kindOfView = 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,26 @@ | ||
import { ViewEventFilter } from './event' | ||
import { ViewLayoutCallback, useViewLayoutTrigger } from './trigger' | ||
import { | ||
ActionPipe, | ||
BaraEventPayload, | ||
ConditionPipe, | ||
createPipe, | ||
useAction, | ||
useTrigger, | ||
} from 'bara' | ||
|
||
export function useViewLayout( | ||
eventFilter: ViewEventFilter, | ||
callback: ViewLayoutCallback, | ||
) { | ||
return useViewLayoutTrigger(eventFilter, callback) | ||
import { BaraReactView, useViewLayoutEvent } from './event' | ||
|
||
export const whenViewLayout = ( | ||
...conditions: Array<ConditionPipe<BaraReactView>> | ||
) => (...actions: Array<ActionPipe<BaraReactView>>) => { | ||
const piper = ( | ||
data: BaraReactView, | ||
payload: BaraEventPayload<BaraReactView>, | ||
) => { | ||
createPipe(data, payload)(...(conditions as any))(...actions) | ||
} | ||
useTrigger<BaraReactView>(() => { | ||
const event = useViewLayoutEvent() | ||
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