LearnNewsExamplesServices
Frontmatter
id4660
titlecore.Base: timeout()
stateClosed
labels
enhancement
assignees[]
createdAtAug 6, 2023, 6:05 PM
updatedAtAug 6, 2023, 6:35 PM
githubUrlhttps://github.com/neomjs/neo/issues/4660
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 6, 2023, 6:35 PM

core.Base: timeout()

Closed v8.1.0 enhancement
tobiu
tobiu commented on Aug 6, 2023, 6:05 PM

We have many classes which are using either Neo.timeout() or setTimeout(). Since instances can literally get destroyed at any moment, it would be nice if timeout callbacks would automatically get removed (via clearTimeout()).

To resolve this:

  • core.Base needs a new timeout() method
  • once called it should store the returned timeoutId inside an instance based array
  • once a timeout is done, it needs to remove its id from the internal array
  • the function needs to return a Promise, so that we can use await me.timeout(50);
  • destroy() needs to check for timeoutIds first and clear them

@ExtAnimal: did I get your idea right?

tobiu added the enhancement label on Aug 6, 2023, 6:05 PM
tobiu referenced in commit 9b309ea - "core.Base: timeout() #4660" on Aug 6, 2023, 6:34 PM
tobiu
tobiu Aug 6, 2023, 6:35 PM

this is the shortest way i can think of. now we can use it inside our classes.

tobiu closed this issue on Aug 6, 2023, 6:35 PM