SDK Cheat Sheet
JavaScript/TypeScript SDK reference cheet sheet.
Reactivity Bridge for Frameworks
context.use(...args: unknown[]) => unknown
Used for frameworks to obtain a reactive pass through to instance properties. For example., if you are working with a framework like React, you might use it to get a getter/setter for a property. The getter/setter is a react store and behaves as expected of a react store.
Properties
context.updateProperty(propertyKey: string, propertyName: string, value:any) => void
Updates the current value of the given property keys based on the return result of the update function.
context.hideProperty(propertyKey: string) => void
Hide a property.
context.showProperty(propertyKey: string) => void
Show a property.
Triggers
context.trigger(propertyKey: string, event: Record<string,unknown>) => void
Used to fire a Trigger event for the given property key. The event object passed to this function will be provided as the event argument to down-stream trigger receivers.
Actions
context.run(propertyKey: string, args: Record<string,unknown>) => void
Used to execute an Action for the given property key. Any additional arguments passed to the run function will be passed to the Action execution.
Data
context.get(propertyKey: string) => unknown
Returns the current value of the given property key.
context.set(propertyKey: string, value: unknown) => void
Sets the current value of the given property key to value. Subscriptions, effects, and related signals bound to property key will trigger after this value is updated.
context.update(propertyKey: string, updateFunction: Function) => void
Updates the current value of the given property key based on the return result of the update function.
context.mutate(propertyKey: string, mutateFunction: Function) => void
Updates the current value of the given property key based on the return result of the mutate function.
Subscriptions
context.subscribe(propertyKey: string | string[], handler: Function) => SubscriptionObject | SubscriptionObject[]
Subscribe to changes when the given property key (or property keys) is changed. The handler is executed any time the property key (or set of property keys) changes.
context.subscribe('*', handler: Function) => SubscriptionObject[]
An alternate version of subscribe is allowed where one provides * as the property key, in which case all properties are subscribed.
context.unsubscribe(propertyKey: string | string[], handler: Function) => void
Unsubscribe from notification when a property changes. One may specify a specific property key or an array of property keys to unsubscribe from. Unsubscribe will only occur on notifications that specifically match the given handler. Because functions are passed by reference in JavaScript/TypseScript this must be a referential match and not a content match.
context.unsubscribe('*', handler: Function) => void
An alternate version of unsubscribe is allowed where one provides * as the property key, in which case all subscriptions that match the given handler function will be unsubscribed.
<SubscriptionObject>.unsubscribe()
Notify
context.notify(state:string, reason: string) => void
Used to visually notify an instance that it is in a given state for a given reason. The possible state values are given below. If an invalid state is given, the notification WILL NOT be displayed.
Rendering
context.render(renderFn: () => HTMLElement) => (el: HTMLElement) => void
Used with nodes that have to render some output. context.render() takes as its sole argument a function that when called returns a HTMLElement object. This HTMLElement is then appended DOM as the output of the node.