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

Small update on the website playground #2616

Merged
merged 3 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Add additonal d.ts files to the JavaScript language service and change.
// Add additional d.ts files to the JavaScript language service and change.
// Also change the default compilation options.
// The sample below shows how a class Facts is declared and introduced
// to the system and how the compiler is told to use ES6 (target=2).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ editor.addAction({
contextMenuOrder: 1.5,

// Method that will be executed when the action is triggered.
// @param editor The editor instance is passed in as a convinience
// @param editor The editor instance is passed in as a convenience
run: function(ed) {
alert("i'm running => " + ed.getPosition());
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ var myBinding = editor.addCommand(monaco.KeyCode.F9, function() {
alert('F9 pressed!');
});

// When cleaning up remember to call myBinding.dispose()
// You can't dispose `addCommand`
// If you need to dispose it you might use `addAction` or `registerCommand`
Copy link
Member

Choose a reason for hiding this comment

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

I don't know all about addCommand / addAction, but why would you need to dispose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using monaco-editor in a NextJS app.
I need it to be updated every time an specific hook updates. If I don't dispose it the app gets slow pretty quick.
Now I'm just using addAction because it can be dispose.
It seams like it used to return a dispose then it change and someone forgot to update the playground.

Copy link
Contributor Author

@Xoffio Xoffio Aug 17, 2021

Choose a reason for hiding this comment

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

Here I opened an issue on monaco-react . At the beginning I thought I could use addCommand because in the playground you can see the lines:

// When cleaning up remember to call myBinding.dispose()

But, that is not true anymore. That's why I changed.