1.0.6 • Published 5 months ago

@vatom/view-sdk v1.0.6

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

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.

1.0.6

5 months ago

1.0.5

7 months ago

1.0.4

8 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.0.6

11 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago