Skip to content

Feature request for React Hooks: Handle Spaces initialization in SpacesProvider #265

@mms-uret

Description

@mms-uret

When the <SpacesProvider> React component is used, most of the time, the spaces object needs to be created first.

From the documentation:

const ably = new Realtime.Promise({ key: "VS4Rww.ijkxYg:*****", clientId: 'clemons' });
const spaces = new Spaces(ably);

root.render(
  <SpacesProvider client={spaces}>
    <SpaceProvider name="my-space">
      <App />
    </SpaceProvider>
  </SpacesProvider>
)

It would be nice if, alternatively to the spaces object, the key and the clientId could be passed to the SpacesProvider and the SpacesProvider cares about initializing Ably and Spaces:

  <SpacesProvider key="VS4Rww.ijkxYg:*****" clientId="clemons">
    <SpaceProvider name="my-space">
      <App />
    </SpaceProvider>
  </SpacesProvider>

Or alternatively have an object, which is passed to Realtime.Promise().

This would save some boilerplate code and also would make sure that implementers don't have to remember to put the Spaces initialization into a useMemo()/ useEffect() hook ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions