Questions tagged [injectable]
121 questions
2
votes
1 answer
Mocking an injectable class for testing that other regular clases depend on
I have an abstract class DatabaseManager, and an implementation DatabaseManagerImpl, the latter is annotated like this:
@LazySingleton(as: DatabaseManager)
class DatabaseManagerImpl implements DatabaseManager {
A lot of other classes then depend on…

splaytreez
- 552
- 5
- 13
2
votes
1 answer
Flutter - using retrofit with injectable
I am trying to use retrofit along with injectable
I am following clean architecture, and in the repo class i want to inject the retrofit client but i cant annotate the client with injectable since its abstract and i cant annotate the implementation…

Mohamad Nidal
- 21
- 2
2
votes
1 answer
Flutter injectable - Inject one singleton for several interfaces
I'm trying to register a singleton of one class which implements two interfaces. Is that possible? The generator states, that one interface is not a subtype of it's own.
abstract class IOne { ... }
abstract class ITwo { ... }
@module
abstract class…

Matthias
- 31
- 2
2
votes
2 answers
Injecting generated mock classes into test" environment
Im currently trying to build widget tests for a project (focusing on TDD). I'm using Injectable to generate the dependency injection as well as the environments to swap between various implementations. The problem I'm having is that I'm not able…

Lloyd Richards
- 330
- 3
- 12
2
votes
2 answers
Flutter Firestorage getDownloadUrl() returns NoSuchMethodError
inside my Flutter app I'm trying to upload an image to Firebase Storage and get the URL afterwards. The image is getting uploaded and I can see it in the web interface, but when I call getDownloadUrl() on a valid reference (I can see the relative…

Viktor Stojanov
- 708
- 6
- 20
2
votes
1 answer
How to create custom Forms Validator using a Service?
I created an Injectable Service for a custom Form Validator:
import { Injectable } from '@angular/core'
import { FormControl } from '@angular/forms'
import { Observable, of, timer } from 'rxjs'
import { map, switchMap } from…

Kr1
- 1,269
- 2
- 24
- 56
2
votes
1 answer
Singleton injection with parameter
I do want to use the packages get_it and injectable. They are both wonderful, but I'm facing a issue. Maybe my idea is wrong.
My application has two singletons and I want to use different base urls for different app flavors. So I added a parameter…

mars3142
- 2,501
- 4
- 28
- 58
2
votes
0 answers
How to pass object to template function of component in angularjs
I have a angularjs 1.7.x project which I used a component to add image and links in a page of website, like below:
angular.module('app', [])
.controller('MainCtrl', function MainCtrl() {
this.book = {
id: 12,
name: 'Spawn'
…

Behzad
- 3,502
- 4
- 36
- 63
2
votes
0 answers
Angular: Injectable() decorator with abstract class
I encountered strange situation and want to discuss is it correct or not.
(please also look for little question update at the end)
In angular 4.3 I have some abstract class which is extended by few angular components. It looks like:
export abstract…

Max Minin
- 453
- 1
- 4
- 8
2
votes
1 answer
In Angular2, how do I use a value from an injected service to set a static variable?
I have a service that provides config data.
@Injectable()
export class ConfigData {
someObj: any;
constructor(private http: HttpClient) {
this.http.get('/config-data').subscribe((data) => {this.someObj = data})
}
}
And now…

CodyBugstein
- 21,984
- 61
- 207
- 363
2
votes
0 answers
Angular 4 - DI: How to inject IntersectionObserver in my Components
As I would like to use the fade-in on scroll feature you can see on many websites, I would like to know how to implement such functionality in my application the "angular way".
I already have a component implementation that works and maybe this…

BigPenguin
- 264
- 2
- 17
2
votes
2 answers
Ionic 2 - Services unexpected token error
I am trying to use an Injectable in my code in an Ionic 2 app and I get this error.
Module build failed: SyntaxError: /home.js: Unexpected token (10:25)
export class HomePage {
constructor(myservice: WpService) {
^
…

Raja Yogan
- 918
- 8
- 17
2
votes
1 answer
Angular2 decorators are not defined
My project builds with webpack but when I host the app from localhost I get an error.
Uncaught ReferenceError: __decorate is not defined.
Initially i get the error with the Injectable() decorator. But when I uncomment that I get the same error but…

smoss
- 39
- 1
- 9
1
vote
0 answers
Injected repository on ValidatorConstraintInterface returns undefined
Good night everyone, I'm working on a NestJs project, attempting to use a custom validator which requires using a repository. Right now the repository is undefined when I call the validate method, I don't finish to understand decorators and frankly…

Santiago Capdevila
- 125
- 1
- 1
- 13
1
vote
1 answer
unable to register an abstract class in using injectable and get_it packages
I'm using injectable and get_it in flutter dart (following the very popular Reso coder)
I have a simple abstract class:
import 'package:injectable/injectable.dart';
//@injectable
abstract class IRandomQuantityRepository {
Future…

MetaStack
- 3,266
- 4
- 30
- 67