@roomy-chat/sdk
    Preparing search index...

    Class EntityWrapper

    A convenient wrapper around an Entity.

    EntityWrapper is the parent of all of the more convenient entity types such as Message or Space.

    Each subclass will usually add it's own accessors that allow for conveniently modifying the underlying Entity's component data.

    You are welcome to extend this type yourself ot add custom convenient entity classes.

    Hierarchy (View Summary)

    Index

    Methods

    • Checks whether the given wrapper type matches the this entity.

      Type Parameters

      Parameters

      • constructor: T

      Returns boolean

    • Register a callback that will be run when the entity is committed.

      Parameters

      • listener: () => void

      Returns () => void

      A function that may be called to unregister the callback.

    • Checks whether the given entity matches this wrapper type.

      The default implementation is to return true for every entity, but some wrappers will override it to check for the existence of certain marker components.

      Parameters

      Returns boolean

    General

    • get id(): `leaf:${string}`

      The string entity ID.

      Returns `leaf:${string}`

    • Commit any changes made to the entity.

      Important: You must call commit after making changes in order for those changes to be immediately applied, reacted to, and synced to network and/or storage.

      Returns void

    • Create a new entity of the given type.

      This can be used to create a new Entity for any type that implements EntityWrapper.

      const roomy = await Roomy.init(peer, catalogId);
      const space = roomy.create(Space);

      Note: This method is inherited from EntityWrapper on all entity types, and it doesn't matter which type you call create() on, they are all equivalent.

      Type Parameters

      Parameters

      Returns Promise<T>

    Advanced

    entity: Entity

    The underlying Leaf Entity.

    peer: Peer

    The leaf peer instance.