Isola92 / PartyScrobbler

1 stars 0 forks source link

Split up reducer #10

Open Isola92 opened 7 years ago

Isola92 commented 7 years ago

Reducer should be split up. Create one for each area of responsibility:

Create inheriting action types for the different reducers. This type will be used to decide which reducer the call should flow through.

Any remaining state should be moved out to the State object. There is some stuff left in APICommunicator.

Isola92 commented 6 years ago

I've decided to extend the ServerActivity class with new types for each reducer.

Each reducer should contain a class for activities and the notify method.

State will still be contained in the CentralDispatcher.

Example: new ServerActivity(API_RECEIVED_NEW_TRACK) new ServerActivity(SOCKET_RECEIVED_NEW_TRACK)

Will be: new SocketActivity(RECEIVED_NEW_TRACK) new APIActivity(RECEIVED_NEW_TRACK)

This syntax makes it easier to keep track of different types of activities without having to add an additional section to the action name.

Isola92 commented 6 years ago

This is kind of done now. One problem that happened during the refactor was that I sometimes passed the wrong action. Which caused nothing to happen at all. This could've been prevented if the actions where mapped to the reducers.

Another issue was that I called the wrong activity in a few scenarios (API instead of Socket etc). This is more difficult to prevent I guess ^^.