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 dataid: the value is attached to its id in the store and when an event is fired, it has this idisGlobal: Is the value stored in the global data or attached to the user in the user dataisSended: Does an event is sent with the given id (TheuseReadneeds 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))
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 sentid: The useRemember hook's iduserId: If unset, read from the animator else read from the given userparse: this function receive the value stored in db and converts it to match the hook's type
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 userValueid: The useRemember hook's idparse: this function receive the value stored in db and converts it to match the hook's type