strvcom / ios-chat-component

Chat modular library
MIT License
1 stars 1 forks source link

[feat] add state of core to be observed and can be read #28

Closed cejanen closed 4 years ago

cejanen commented 4 years ago

Added chat core state and its possible observation For now its just at core its question if we should propagate it to chat itself.

cejanen commented 4 years ago

Since we have states connecting and connected I believe it would be nice to implement also reachability and whenever there is no network the state changes to connecting

@schwarja Isnt that something else? We're using it to detect initial state. But if I imagine I loaded conversations and later just when sending message networks go down I dont wanna see any error or progress bar that whole chat component is connecting? Its connected -> means it knows its network layer and can communicate. At least what I feels it should be.

schwarja commented 4 years ago

@cejanen I took inspiration from Messenger that indicates if there is no connection. It is a nice way to say: "We are trying our best to send your message but there is no internet connection right now"

As I suggested in the Trello ticket, I think we could have these states:

  1. Initial - Default state, just to have it complete
  2. Loading - While the chat component is being initialized
  3. Ready - Let's get rid of it as it is duplicate of connected
  4. Connected - The chat component has been initialized and it has an internet connection
  5. Connecting - The chat component has been initialized but it doesn't have an internet connection right now
cejanen commented 4 years ago

@schwarja I added reachability into project. Again as file instead of pod. I also created reachability observer to wrap some observing and cleanup logic. There is try? bc it shouldnt throw regularly. At chat core I updated changes of chat core states. I was thing about adding any guard to all calls to avoid calling when state is connecting but I decided to keep it as it is and add this state changes as option to react at UI. Also this change would create all calls more complex.

cejanen commented 4 years ago

Hopefully all good :-D