5

Suppose, i want to keep some non-serializable data for my applciation, which the user can access and interact with across the application. So for example, a connected device (bluetooth, wlan), a media stream, something of this sort. Im wondering where to put such data, when using the Redux paradigm?

Pseudocode:

A normal lifecycle of a subscription might look like this:

Subscription connection = instance.connect(device, request).listen();
...
connection.send(data);
...
data = connection.read();
...
connection.unsubscribe();

the app store might look like this:

Store:

{
  username: '',
  friends:[],      <--- Pulled from the server with async middleware
  connections:[],  <--- Connections data here ???
}

But I would go on and say, that such a device subscription or media stream is not serializable and therefore it would be not proper, to hold them in the Redux Appstate.

And i'm aware, that for example for server request, one is encouraged to use middleware. So for friends of the user, one would write asynchronous actions to pull the friends user names from the server at the login of a user. But a device id in the state wont do, since one has to actually interact with the device connection stream in the app.

So would writing a seperate middleware be an acceptable way to hold on to such data? What is the common practice herefore?

scrimau
  • 1,325
  • 1
  • 14
  • 27

0 Answers0