Skip to content

Commit

Permalink
feat(bara): add whenReactAppMounted trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
nampdn committed May 2, 2019
1 parent f923459 commit 68a1108
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/bara.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventType, register, useInit, useEmitter, createEmitter, createEventType, useStream } from 'bara'
import { EventType, register, useEvent, useAction, useTrigger, useInit, useEmitter, createEmitter, createEventType, useStream } from 'bara'
import React, { ComponentType, useEffect } from 'react'
import { AppRegistry } from 'react-native'

Expand Down Expand Up @@ -76,3 +76,11 @@ export const useReactApp = ({
}
})
}

export const whenReactAppMounted = (callback: () => void) => {
return useTrigger(() => {
const event = useEvent(REACT_APP_MOUNTED)
const action = useAction(callback)
return {event, action}
})
}

0 comments on commit 68a1108

Please sign in to comment.