Skip to content
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

Evaluate all code blocks below current block with same scope #35

Merged
merged 2 commits into from
Jul 31, 2018

Conversation

matthiaskern
Copy link
Collaborator

Additionally I think clearing up widgets in lower blocks should be cleared when the current field is updated.

@@ -10,7 +10,7 @@ let renderErrorIndicator = (colStart, colEnd, content) =>
++ "\n"
++ content;

let executeRessultToWidget = (result: list(Worker_Types.blockData)) => {
let executeResultToWidget = (result: list(Worker_Types.blockData)) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I blame @-jaredly for this. His reason-language-server is so good that I just tab tab tab


let executeMany:
Belt.Map.String.t(string) => Belt.Map.String.t(list(blockData)) =
codeMap => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an explicit uncurried function. Bucklescript and ES6 proxy doesn't play nice with each others.

(. codeMap) =>

Copy link
Member

@thangngoc89 thangngoc89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments. I hope you can fix it as we are running the code in a browser. Toplevel is already a resources hugger

)
}
};
| Block_Execute(_blockId) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not using it then we better remove _blockId completely

| Block_Execute(_blockId) =>
let allCodeBlocks =
Belt.Map.String.fromArray(
state.blocks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really inefficient (3n). We can do this in a single loop like this:

module MS = Belt.Map.String;

state.blocks 
|. Belt.Array.reduceU(MS.empty, (. map, {b_id, b_data}) => {
  switch (b_data) {
  | B_Text(_) => map
  | B_Code({bc_value}) => map |. MS.set(b_id, bc_value)
  }
}))

As always, I didn't test this code :D

| B_Text(_) => map
| B_Code({bc_value}) => map |. MS.set(b_id, bc_value)
}
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whaaaaaaat. This really works huh?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually does! 💯

Copy link
Member

@thangngoc89 thangngoc89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect !

@thangngoc89 thangngoc89 merged commit 879b25f into master Jul 31, 2018
@thangngoc89 thangngoc89 deleted the connected-fields branch August 12, 2018 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants