Open brunomoutinho opened 1 year ago
@ericelliott I am facing a problem and would like your feedback.
Currently, the connect
SDK is being instanced in whatever component that wants to use them.
Ideally, we should not have many instances of the SDK at the same time, I believe, since we have the store being created and managed inside of the SDK.
From there, I was thinking about how to instantiate the SDK and thought it would be nice to have a Provider/Hook pattern to access the SDK. So I created them, the SDK is instantiated when the Provider is created. This sounds great, but this makes it not feasible to use the SDK in Redux Sagas, for example, because you cannot access the Provider state from outside of the component tree.
This made me think that we could use a Singleton pattern. This makes the Provider/Hook pattern unnecessary if I expose a method that gets the Singleton SDK instance (which could be something like useConnect
, which resembles the hook pattern), and can also be used in the Redux Sagas.
How do you feel about this solution? Is there any other pattern I should explore?
When a client initializes a connect client, they should have some way to know about a user's sign in status updates.
Proposed solution:
API Usage:
/docs
folder