@vatom/view-sdk
v1.0.4
Published
## Table of Contents
Downloads
67
Keywords
Readme
VATOM - View SDK
Table of Contents
Installation
yarn install @vatom/view-sdk
Getting Started
There are two ways to get started. By adding useViewSDK
hook in your App or wrap your App component with a HOC withVatom
import { useViewSDK } from '@vatom/view-sdk'
const App = () => {
const { businessId, trackEvent, sendRequest, awaitResponse, performAction } = useViewSDK()
return (
<View>
<Text>Example {businessId}</Text>
</View>
)
}
import { withVatom } from '@vatom/view-sdk'
const App = withVatom(
({ businessId, trackEvent, sendRequest, awaitResponse, performAction, viewConfig }) => {
return (
<View>
<Text>Example {businessId}</Text>
</View>
)
}
)
Usage
const { businessId, trackEvent, sendRequest, awaitResponse, performAction, viewConfig ...state } = useViewSDK()
// state
// {
// vatom: VatomModelInput
// children: VatomModelInput[]
// isLoading: boolean
// isError: boolean
// error?: unknown
// userData: UserModelInput | null
// isVerifiedUser: boolean
// shareLink: string
// isMocked: boolean
// mockedState: Record<string, unknown>
// }
Custom listeners
In order to use custom event listener first initialize useMessageListener
import { useEventListener, useMessageListener } from '@vatom/view-sdk'
const MyApp = () => {
//
useMessageListener()
const myCallback = (data?: unknown) => {
console.log('> myCallback', data)
}
useEventListener('viewer.view.ready', myCallback)
return (
<View>
<Text>Example :)</Text>
</View>
)
}
This library was generated with Nx.