Comments (7)
I'd like to second this statement, especially as detailed here: glimmerjs/glimmer.js#235 (comment)
The absence of such API forces implementors to use unpleasing (to say the least) workarounds ;)
from glimmer-experimental.
@argarcia-ottersoft workaround exists, you could pass service into component and inside it's contructor assign this to some service property.
class App extends Component {
@service app;
constructor() {
super(...arguments);
this.app.setComponent(this);
}
}
class MyService {
component = null;
setComponent(value) {
this.component = value;
}
}
const appService = new MyService();
await renderComponent(App, { services: { app: appService } } )
appService.component === App instance
from glimmer-experimental.
@argarcia-ottersoft there is issue for it - #123
But, I could assume that minimal unload logic should be like:
// app's hbs
class App extends Component {
@tracked
isAlive = true;
async destroy() {
this.isAlive = false;
await new Promise((resolve) => setTimeout(resolve)); // need to wait for rerender
// nested components should be destroyed here and all you need is cleanup services used for component
}
}
from glimmer-experimental.
any update on this? any workarounds?
from glimmer-experimental.
awesome! thanks @lifeart
follow up question, is there any way to properly unload the component? I'm trying to do cleanup in web components disconnectedCallback method
from glimmer-experimental.
@lifeart, any reason why a nested component in App's {{#if this.isAlive}}<ChildComponent />{{/if}}
would not fire the willDestroy() hook after setting the App's isAlive property to false? The <ChildComponent />
does successfully get removed from the screen
from glimmer-experimental.
never mind, it was an error on my end. An exception was being thrown while looping through scheduledDestructors cause of a version mismatch of @glimmer/destroyable. glimmer-class-based-modifier depended on version 0.77.3 while glimmer.js depended on 0.77.6 so updating glimmer-class-based-modifier to 0.77.6 fixed issue.
from glimmer-experimental.
Related Issues (20)
- Fresh app from blueprint doesn't build HOT 4
- Integration with other projects HOT 1
- prettier-plugin: Improve implementation to work for import alias of hbs
- API to destroy rendered app
- expose cache and storage primitives HOT 1
- new glimmer project doesn't build with default babel rc
- registerDestructor doesn't call on destruction
- Issue with Template Tag within storybook
- Using `{{yield}}` in component prevents usage of `{{on}}` modifier HOT 2
- APIs not working
- RFC to remove GlimmerX from Glint HOT 1
- Future ESLint plugin improvments HOT 2
- eslint-plugin doesn't support {{yield}} HOT 1
- Inconsistent TypeScript declarations HOT 1
- Inconsistency between function and non-function scope binding HOT 2
- Module not found: Error: Can't resolve '@glimmer/bundle-compiler' HOT 4
- Typescript: Bug during parsing components inside components
- @ember/test-helpers render() style integration tests currently not possible HOT 2
- BUG/Requirement: render() test-helper: currently impossible to set services & `this` context for templateOnlyComponents
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glimmer-experimental.