Vscode-jupyter: Use redux and redux-react to handle our state in our Notebook Editor/Interactive Window

Created on 12 Oct 2019  路  3Comments  路  Source: microsoft/vscode-jupyter

Our state is getting rather complex (and large).

Redux gives us the following benefits

  • Potentially easier state updates
  • Better logging about state transitions
  • Better separation of state modifications

Most helpful comment

My first idea would be to

  • Potentially rework our state to have something like (why are we maintaining the Cell structure?)

    • Inputs [] of some object

    • Outputs [] of cell output types

    • View Props [] of cell view states (selected, focused, markdown/code)

  • Move all state modifications into a set of reducers

    • Could have reducers for different parts of state (input/output/selection)

  • Change mainStateController to just be a MailBox or something like that simply listens to messages from the extension side
  • Change the UI to dispatch to redux instead of having to go through the main state controller
  • Change UI updates to be controlled by redux-react.

All 3 comments

My first idea would be to

  • Potentially rework our state to have something like (why are we maintaining the Cell structure?)

    • Inputs [] of some object

    • Outputs [] of cell output types

    • View Props [] of cell view states (selected, focused, markdown/code)

  • Move all state modifications into a set of reducers

    • Could have reducers for different parts of state (input/output/selection)

  • Change mainStateController to just be a MailBox or something like that simply listens to messages from the extension side
  • Change the UI to dispatch to redux instead of having to go through the main state controller
  • Change UI updates to be controlled by redux-react.

Woohoo.
I'd also suggest using mapStateToProps and mapDispatchToProps.., simplifies how we pass state around ... And invoke actions
Also might want to look at redux thunk (as most of the actions will be async).

Change mainStateController to just be a MailBox or something like that simply listens to messages from the extension side

Agreed... Basically it should be treated like an endpoint (rest + websocket)... It's just a bidirectional communication layer..

Moving this back to triage. This is going to make a lot of the bugs we have to fix easier. I'd like to do this now, rather than wait (and have those bug fixes get progressively harder and harder to implement)

Was this page helpful?
0 / 5 - 0 ratings