tracked-tools / ember-could-get-used-to-this

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

initial-implementation - effect cleanup not called when DEBUG is true

pqmcgill opened this issue · comments

Hello,

First off, this library is awesome, and I do understand that it is very much a work in progress. With that said, there appears to be an issue on the initial-implementation branch in which the provided effect function, when given a function that returns a cleanup function, does not invoke the cleanup function correctly when the component is destroyed. This only happens while running in the local development mode

in the following example, when DEBUG is true and when the Test component is destroyed, the second log will never execute:

import Component from '@glimmer/component'
import { use, effect } from 'ember-usable'

class Test extends Component {
  constructor(owner, args) {
    super(owner, args)
    use(this, effect(() => {
      console.log('effect is run')
      return () => console.log('cleanup is run')
    })
  }
}

I hope this is helpful, and please let me know if more description is needed. Meanwhile, I will do some digging and see if I can come up with a PR. Thanks!

EDIT:

I've published a PR here #5 that fixes the issue I was seeing

I'm going to close this issue since the initial implementation has changed significantly. Let me know if this is still a problem on the latest version!