DEV Community

bronifty
bronifty

Posted on

Injectable Class Means Dependencies Loaded Automatically

Angular's Dependency Injection (DI) is based on injectable classes, which load dependencies when the class is built into an object with new.

@Injectable()
export class TodoEffects {
  constructor(
    private actions$: Actions,
    private store: Store<AppState>,
    private todoService: TodoService
  ) {}
}
Enter fullscreen mode Exit fullscreen mode

code excerpt from Josh Morony's video on ngRX here: https://www.youtube.com/watch?v=kx0VTgTtSBg&list=WL&index=4

Incidentally, there are an extremely large number of concepts in modern web apps which borrow from the ideas of Angular and RXJS (reactive state). It almost makes sense to get a hang of these ideas if only for a history lesson. I think these are great fundamentals either way.

Also, async programming (the JS style) is like a slinky. It's not coming directly down the stairs, but once you drop it, you know it's getting there.

Top comments (0)