General concepts
This guide covers common patterns and concepts used throughout the Felt SDK.
By following these patterns consistently throughout the SDK, we aim to make the API predictable and easy to use while maintaining flexibility for future enhancements.
Use of promises
All methods in the Felt SDK are asynchronous and return Promises. This means you'll need to use await
or .then()
when calling them:
Getting entities
The SDK follows a consistent pattern for getting entities. For each entity type, there are usually two methods:
A singular getter for retrieving one entity by ID:
A plural getter that accepts constraints for retrieving multiple entities:
The plural getters allow you to pass no constraints, in which case they'll return all entities of that type:
Change listeners
Each entity type has a corresponding change listener method following the pattern on{EntityType}Change
:
This is true of selection, which acts as a kind-of entity in its own right:
Cleanup functions
All change listeners return an unsubscribe function that should be called when you no longer need the listener:
This is particularly important in frameworks like React where you should clean up listeners when components unmount:
Handler and options structure
Change listeners always take a single object parameter containing both options
and handler
. This structure makes it easier to add new options in the future without breaking existing code:
Entity nodes
When dealing with mixed collections of entities (like in selection events), each entity is wrapped in an EntityNode
object that includes type information:
Last updated