Market Service
This provides a service for other components to use to retrieve market information.
Requirements
The Market Service interface:
export interface Market {
name: string;
id: string;
}
export interface MarketServiceInterface {
getMarkets(): Observable<Market[]>;
}
To implement the interface make a new service that implements the interface:
…
import {MarketServiceInterface} from '@vendasta/core';
@Injectable()
export class MarketService implements MarketServiceInterface {
…
getMarkets(partnerId: string): Observable<Market[]> {
}
}
Next you will need to provide your service as that interface (generally in app.module.ts
)
import { MarketServiceImpl } from './market.service';
import { MarketServiceInterfaceToken, MarketModule } from '@vendasta/core';
…
@NgModule({
…
imports: [MarketModule],
providers: [
{provide: MarketServiceInterfaceToken, useExisting: MarketServiceImpl}
],
})
- Note: To be able to inject an interface, you will have to provide the InjectionToken and not the interface itself (
MarketServiceInterfaceToken
vs MarketServiceInterface
).