Skip to main content

SDK Hooks

useRemember()

useRemember<T>(defaultValue: T, id: string, isGlobal = false, isSended = true, parse: (value: any) => T)

Store the given value in db and gets it when loading for the first time.

Type: [value, setValue] Parameters:

  • defaultValue: the value saved when it's undefined in the global or user data
  • id: the value is attached to its id in the store and when an event is fired, it has this id
  • isGlobal: Is the value stored in the global data or attached to the user in the user data
  • isSended: Does an event is sent with the given id (The useRead needs it)
  • parse: this function receive the value stored in db and converts it to match the hook's type
// transform the string in db to a Date object
useRemember(new Data(), 'date', true, false, (date) => new Date(date))

Learn how to use it

useRead()

useRead<T>(defaultValue: T, id: string, userId?: string , parse: (value: any) => T)

Reads a useRemember hook's value.

Type: value: T Parameters:

  • defaultValue: the return value will be equal to the default value until it finds it in the db, or it's sent
  • id: The useRemember hook's id
  • userId: If unset, read from the animator else read from the given user
  • parse: this function receive the value stored in db and converts it to match the hook's type

Learn how to use it

useReadAll()

useReadAll<T>(defaultValue: T, id: string, parse: (value: any) => T)

Reads every useRemember hook's values.

Type: value: T Parameters:

  • defaultValue: The default value for each userValue
  • id: The useRemember hook's id
  • parse: this function receive the value stored in db and converts it to match the hook's type

Learn how to use it