-
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(functions): new opearator useComponentsStream for register all s…
…tream at once (can exclude)
- Loading branch information
Showing
4 changed files
with
51 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,2 +1,3 @@ | ||
export * from './use-barn-state' | ||
export * from './barn-bridge' | ||
export * from './barn-bridge' | ||
export * from './use-components-stream' |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as ExportedStreams from '../exports' | ||
|
||
export interface UseComponentsStreamConfig { | ||
Text?: boolean | ||
Touchable?: boolean | ||
TouchableOpacity?: boolean | ||
View?: boolean | ||
} | ||
|
||
const defaultConfig: UseComponentsStreamConfig = { | ||
Text: true, | ||
Touchable: true, | ||
TouchableOpacity: true, | ||
View: true, | ||
} | ||
|
||
/** | ||
* Register all components as Bara stream | ||
*/ | ||
export function useComponentsStream(config?: UseComponentsStreamConfig) { | ||
const combinedConfig = { ...defaultConfig, ...config } | ||
for (const component in combinedConfig) { | ||
if ((combinedConfig as any)[component] === true) { | ||
const methodName = `use${component}Stream` | ||
if (methodName in ExportedStreams) { | ||
;(ExportedStreams as any)[methodName]() | ||
} | ||
} | ||
} | ||
} |