Question about onremove
See original GitHub issueYou guys are probably getting tired of me asking silly questions. 😃 I’m creating an Ace interop example for a presentation and not seeing the onremove fire when removing DOM elements… I’m thinking I need to somehow properly dispose of Ace. Here’s my code.
const AceComponent = ({ model, actions}) => {
const css = {
height: "200px",
width: "800px",
marginTop: "20px",
marginBottom: "20px"
}
const setupEditor = (e) => {
const editor = ace.edit(e);
editor.setTheme("ace/theme/cobalt");
editor.getSession().setMode("ace/mode/javascript");
editor.setValue(model.editorText, 1);
editor.getSession().on('change', _ => actions.setEditorText(editor.getSession().getValue()))
}
const disposeEditor = (e) => {
console.log("dispose editor?");
// ace.editor(e).destroy(),
}
return (
<div>
<div style={css} oncreate={setupEditor} onremove={disposeEditor}></div>
<div>{ model.editorText }</div>
</div>
)
}
app({
model: {
showEditor: true,
editorText: "// welcome to the ace editor \rconsole.log(\"hyperapp is the bee's knees!\");"
},
reducers: {
setEditorText: (model, text) => ({ editorText: text }),
toggleEditor: (model) => ({showEditor: !model.showEditor})
},
view: (model, actions) => (
<div>
<input type="button" value="toggle editor" onclick={ _ => actions.toggleEditor() } />
{ model.showEditor && (<AceComponent model={model} actions={actions}></AceComponent>)}
</div>
)
})
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
onRemove()-event? - javascript - Stack Overflow
I'm not trying to add a handler to the array itself, but to the DOM element (input) so that the input itself can...
Read more >Leaflet onRemove Control - GIS Stack Exchange
Leaflet onRemove Control · 0 · Know someone who can answer? Share a link to this question via email, Twitter, or Facebook. ·...
Read more >Table onRemove - node removed from model but not context
Hello, I am having an issue where if I remove a node a from table in UI it is not reflect in my...
Read more >onDelete action not working through ef6 - Microsoft Q&A
my WPF Application language is c# and used Entity Framework 6 and I have a SQLite database that one of tables has Foreignkey...
Read more >RE: How to use onRemove() in Liferay Autofields? - Forums
I need to use the Liferay auto-fields to add a question block. ... 2) onRemove: function() { alert('The last field was removed.'); }...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think that from the perspective of a HyperApp end user, it seems reasonable that when the element “goes away” that onremove would then be called.
@cdeutmeyer Sorry, I meant this as a general question, what I am trying to ask is: why would one need to use onremove?
Exactly, why is this necessary? JavaScript has GC, or if you are toggling the editor, then you can call your
disposeResources()
function or similar inside that toggle effect.Am I making sense?