UNPKG

@apollo-orbit/angular

Version:

A full-featured GraphQL client for Angular

40 lines (34 loc) 2.51 kB
import { ActionType, Action, ActionInstance, State } from '@apollo-orbit/core'; export { Action, ActionContext, ActionFn, ActionInstance, ActionType, EffectFn, FragmentMap, MutationIdentifier, MutationInfo, MutationUpdateFn, OptimisticResponseFn, RefetchQueriesFn, State, TypeField, state } from '@apollo-orbit/core'; import { OperatorFunction, Observable } from 'rxjs'; import * as i0 from '@angular/core'; import { EnvironmentProviders } from '@angular/core'; import { ApolloOrbitFeature } from '@apollo-orbit/angular'; type ActionStatus = 'dispatched' | 'success' | 'error'; interface ActionExecution<TAction = any, TError = Error> { status: ActionStatus; action: TAction; error?: TError; } interface ActionComplete<TAction = any, TError = Error> { action: TAction; error?: TError; status: Extract<ActionStatus, 'success' | 'error'>; } declare function ofActionDispatched<TActionTypes extends Array<ActionType<any>>>(...actions: TActionTypes): OperatorFunction<ActionExecution<InstanceType<TActionTypes[number]>>, InstanceType<TActionTypes[number]>>; declare function ofActionSuccess<TActionTypes extends Array<ActionType<any>>>(...actions: TActionTypes): OperatorFunction<ActionExecution<InstanceType<TActionTypes[number]>>, InstanceType<TActionTypes[number]>>; declare function ofActionError<TActionTypes extends Array<ActionType<any>>>(...actions: TActionTypes): OperatorFunction<ActionExecution<InstanceType<TActionTypes[number]>>, InstanceType<TActionTypes[number]>>; declare function ofActionComplete<TActionTypes extends Array<ActionType<any>>>(...actions: TActionTypes): OperatorFunction<ActionExecution<InstanceType<TActionTypes[number]>>, ActionComplete<InstanceType<TActionTypes[number]>>>; declare class ApolloActions extends Observable<ActionExecution> { private readonly registry; private readonly actions; constructor(); dispatch<TAction extends Action | ActionInstance>(action: TAction): Promise<void>; static ɵfac: i0.ɵɵFactoryDeclaration<ApolloActions, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ApolloActions>; } type StateFactory = () => State; declare function withState(...states: Array<State | StateFactory>): ApolloOrbitFeature; declare function provideStates(...states: Array<State | StateFactory>): EnvironmentProviders; export { ApolloActions, ofActionComplete, ofActionDispatched, ofActionError, ofActionSuccess, provideStates, withState }; export type { ActionComplete, ActionExecution, ActionStatus, StateFactory };