I still can't make sense of the types.
Sometimes clarity comes from the chosen names.
Change #1:
// A Dependency has many different Subscribers depending on it // A particular Subscriber has many Dependencies it depends on type Dependency = Set<Subscriber>; type Subscriber = { execute(): void; dependencies: Set<Dependency>; };
Change #2:
const subscriptions: Dependency = new Set();
Change #3:
function cleanup(running: Subscriber) {
Change #4:
const running: Subscriber = { execute, dependencies: new Set(), };
TypeScipt Playground
// A Dependency has many different Subscribers depending on it // A particular Subscriber has many Dependencies it depends on
Yes! This is what the article/video/example was missing. Thank you! 😀🙏
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sometimes clarity comes from the chosen names.
Change #1:
Change #2:
Change #3:
Change #4:
TypeScipt Playground
Yes! This is what the article/video/example was missing. Thank you! 😀🙏