BaseEntityResolver
BaseEntityResolver
A base resolver for an entity detail route. Resolves to an observable of the given entity, or a "blank" version if the route id equals "create". Should be used together with details views which extend the BaseDetailComponent.
Example
@Injectable({
providedIn: 'root',
})
export class MyEntityResolver extends BaseEntityResolver<MyEntityFragment> {
constructor(router: Router, dataService: DataService) {
super(
router,
{
__typename: 'MyEntity',
id: '',
createdAt: '',
updatedAt: '',
name: '',
},
id => dataService.query(GET_MY_ENTITY, { id }).mapStream(data => data.myEntity),
);
}
}
Signature
class BaseEntityResolver<T> {
constructor(router: Router, emptyEntity: T, entityStream: (id: string) => Observable<T | null | undefined>)
}
constructor
method
(router: Router, emptyEntity: T, entityStream: (id: string) => Observable<T | null | undefined>) => BaseEntityResolver