injectable Questions

2

Solved

Usually I'd go like this in my component. import { Router } from "@angular/router"; @Component({ ... }) export class CompyTheComponent { constructor(private router: Router) { console.log(route...
Bluenose asked 22/8, 2017 at 17:44

2

I have something like that: @injectable class SettingsBloc { final Event event; SettingsBloc(@factoryParam this.event); } When I call it from my code, I pass factory param like: getIt<Settin...
Sucrase asked 8/12, 2020 at 5:46

4

Solved

I have a problem trying to unit test an angular service. I want to verify that this service is properly calling another service that is injected into it. Lets say I have this ServiceToTest that in...
Arcadia asked 22/12, 2017 at 8:48

1

I have a bloc, that I want to register for DI: @injectable class ViewBloc<T> extends Bloc<ViewEvent, ViewState> { } As you can see the ViewBloc takes a generic type param T. The proble...
Algometer asked 29/9, 2021 at 6:20

3

Solved

In my library I have a service with this code: import { Inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { DataInjectorModule } from '../../data-...
Streetwalker asked 16/10, 2020 at 14:43

0

Is it fine to get instances from getIt initialised in lib(dev) code or should I use another way, or another DI setup for tests? Please refer the code below: void main() { TravellerProfileViewMode...

2

Solved

im using injectable and get_it package in flutter i have a shared preference class : @LazySingleton() class SharedPref { final String _token = 'token'; SharedPreferences _pref; SharedPref(this....

0

I have an Angular application which initialises Web Worker and starts some rendering operations inside it. Worker has instance of helper class Renderer to perform rendering operations. Now I need ...
Daglock asked 22/10, 2019 at 14:39

3

Solved

With the change from Angular 5 where you provide service in AppModule to Angular 6 where you set 'provideIn' key in @Injectable decorator I have changed all services to use new "provideIn" method. ...
Sorcha asked 7/5, 2018 at 9:38

2

Solved

I don't understand When to use @Inject and when to use @Injectable ? import {Component, Inject, provide} from '@angular/core'; import {Hamburger} from '../services/hamburger'; export class App...
Malicious asked 19/5, 2016 at 6:22

1

Solved

I'm trying to implement an auth guard in my app. ie; Only authenticated users can access certain routes of my app. I'm following the tut given here. Once the user is logged in I change a boolea...
Revocation asked 30/12, 2016 at 6:54

2

Solved

Is it possible to do something like this? (cause I tried, and haven't succeed): @Injectable() class A { constructor(private http: Http){ // <-- Injection in root class } foo(){ thi...

1

When writing code we should be able to identify two big group of objects: Injectables Newables http://www.loosecouplings.com/2011/01/how-to-write-testable-code-overview.html http://misko.hever...

3

Solved

Assume you divide up your systems in Value objects and Services objects (as suggested in "Growing Object-Oriented Software, Guided by Tests". Misko Hevery calls these "newables" and "injectables". ...
Pontus asked 25/6, 2010 at 12:3
1

© 2022 - 2024 — McMap. All rights reserved.