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
Update Bee API methods to go directly through executionInfo #20890
Conversation
3931bbd
to
113a913
Compare
e616919
to
9ac362e
Compare
PTAL |
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.
I like it.
apps/src/maze/api.js
Outdated
@@ -258,11 +258,15 @@ exports.loopHighlight = API_FUNCTION(function (id) { | |||
* whether or not we're a Bee level | |||
*/ | |||
exports.getNectar = API_FUNCTION(function (id) { | |||
Maze.subtype.getNectar(id); | |||
if (Maze.subtype.getNectar()) { |
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.
Maybe this should be tryGetNectar
, just so it's more clear that it attempts to get nectar?
Perhaps that would change back when you pull the termination value out of the subtype, so I'll leave it up to you.
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.
hmm, maybe I should update the comment.
It not only attempts to get nectar, but also does so if it can, via this line.
The way the maze code execution works (which is probably a bit more complicated than it needs to be) is that is makes all the api calls which as a side effect runs all the headless stuff, then resets the environment and runs the queued animation actions.
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.
That's the behavior I'd expect from a tryFoo
method (i.e. actually do foo
, or return false if foo
would throw/actually does throw an exception), but I suppose that expectation is not as universal as I had thought.
I think the comment is fine as is.
26ac017
to
80d958e
Compare
Rather than calling a subtype method which THEN queues an action which then calls a subtype method, this PR untwitsts things to make the flow of execution more linear
…, make the api responsible for conditionally connecting them
…ent their return values
80d958e
to
8c75ba1
Compare
Rather than calling a subtype method which THEN queues an action which
then calls a subtype method, this PR untwitsts things to make the flow
of execution more linear.
Okay, so Subtypes that support Quantum maps need to provide two versions of their major methods:
executionInfo.terminateWithValue
if it can't complete successfully. This is used for the validation of the Quantum maps to see if the user's code passes.We have so far been calling those methods like this:
executionInfo.queueAction
to queue up the animation methodBut this means that subtypes need to know about execution info and action queuing. I instead propose we change our expectations to add a requirement that the headless version will return a boolean representing whether or not the validation passed. We can then:
This means that subtypes no longer need to know about action queuing, and just need to know enough about executionInfo to be able to terminate if something goes wrong.
Then, in a future PR, I can refactor that away, too, and subtypes will no longer need to have any concept of a user's code being executed.