New: Headless Commerce with Remix! read more

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<MyEntity.Fragment> {
  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> implements Resolve<Observable<T>> {
  constructor(router: Router, emptyEntity: T, entityStream: (id: string) => Observable<T | null | undefined>)
}

Implements

  • Resolve<Observable<T>>

Members

constructor

method
type:
(router: Router, emptyEntity: T, entityStream: (id: string) => Observable<T | null | undefined>) => BaseEntityResolver