Code Monkey home page Code Monkey logo

Comments (6)

georgedaters avatar georgedaters commented on September 26, 2024

@Tealons I think I've experienced that same issue. In every page that uses the editor, try have the page implement the IDisposable interface then in the Dispose method call Editor.DisposeEditor() (where Editor is a reference to the StandaloneCodeEditor component)

from blazormonaco.

chrisonmoon avatar chrisonmoon commented on September 26, 2024

Hello - i have the same problem.

The solution with Dispose() did not work...

from blazormonaco.

StephenOTT avatar StephenOTT commented on September 26, 2024

Having the same issue.

public async ValueTask DisposeAsync()
    {
        await editor.DisposeEditor();
        editor.Dispose();
    }

or just

public async ValueTask DisposeAsync()
    {
        await editor.DisposeEditor(); 
   }

does NOT work.

from blazormonaco.

StephenOTT avatar StephenOTT commented on September 26, 2024

So:

doing (pulled from the readme)

private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{
	return new StandaloneEditorConstructionOptions
	{
		AutomaticLayout = true,
		Language = "javascript",
		Value = "function xyz() {\n" +
				"   console.log(\"Hello world!\");\n" +
				"}"
	};
}

/ using the Value prop seems to be what causes the problem.

If you create a method on the

<StandaloneCodeEditor @ref="@editor" Id="my-editor" ConstructionOptions="@EditorConstructionOptions" OnDidInit="InitEditor"/>

private async Task InitEditor()
    {
        await editor.SetModel(await Global.CreateModel("some content here", "javascript"));
    }

Then everything seems to work. And i did not have to implement IDisposable

Though it raises suspicions / concerns that there is a memory leak or something is being cached?

from blazormonaco.

mmauri avatar mmauri commented on September 26, 2024

The approach shown by @StephenOTT works,
but I had to inject the JS runtime to make it work with Blazor server

private async Task InitEditor()
{
  await editor.SetModel(await Global.CreateModel(jsRuntime, "SELECT * FROM TABLE", "sql"));
}

from blazormonaco.

adamdriscoll avatar adamdriscoll commented on September 26, 2024

I think this is the same issue as: #136

Seems like this PR would fix this: #137

from blazormonaco.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.