-
-
Notifications
You must be signed in to change notification settings - Fork 111
async-data-example #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async-data-example #173
Conversation
examples/async-data/src/App.js
Outdated
this.setState(prevState => ({ | ||
...prevState, | ||
editorRevision, | ||
plotRevision, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does a user have to manage these things? Because we mutate data? I don't think that is a good enough excuse.
examples/async-data/src/App.js
Outdated
label: name, | ||
})); | ||
this.setState(prevState => ({...prevState, dataSourceOptions})); | ||
this.hub.editorSourcesUpdated(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really? So a user needs to know what is and what is not an editorSource and in each case make sure the hub is available in scope to call this function? really?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be done in the editor with componentWillReceiveProps()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can if figure updates always generate new wrapping containers.
examples/async-data/src/App.js
Outdated
dataSources, | ||
...otherState, | ||
}); | ||
this.hub.figureUpdated(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and it's not just this.hub.editorSourcesUpdated()
you need to keep track of, it's also somehow different from whatever figureUpdated()
does. Nope and Nope.
examples/async-data/src/App.js
Outdated
|
||
onEditorUpdate(event) { | ||
const {type, payload} = event; | ||
if (type === EDITOR_ACTIONS.UPDATE_TRACES) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if we need to intercept the figure updating routine you gotta know how EDITOR_ACTIONS works and which events to tie into ... please 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we could invert control and have the hub fire its own sub-events that apps could hook into, so this would be implemented as hub.onUpdateTrace = ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we eliminate the hub entirely? It still seems a bit ungainly to me. It's a stateful thing but distinct from typical application data handling.
Okay a few scathing comments made. Extra scathing because I am solely responsible for this travesty. Who wants to take lead on figuring out and implementing a better system? |
examples/async-data/src/App.js
Outdated
debug: true, | ||
onUpdate: ({editorRevision, plotRevision}) => | ||
this.setState(prevState => ({ | ||
...prevState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bpostlethwaite why do we do this spread thing here? My understanding of setState
was that it would merge anyway, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes good call
@nicolaskruchten @VeraZab this example is closer to the use case of a particular client's application. I think it is an important example as many real-world cases involve fetching data asynchronously.
Our current system using the hub and revisions is obviously cumbersome. I think this PR may make a good base to fix #172.