UNPKG

@loona/angular

Version:

App State Management done with GraphQL (angular integration)

34 lines (33 loc) 1.54 kB
import { ErrorHandler } from '@angular/core'; import { Apollo, QueryRef } from 'apollo-angular'; import { WatchQueryOptions, MutationOptions as CoreMutationOptions } from 'apollo-client'; import { FetchResult } from 'apollo-link'; import { Observable } from 'rxjs'; import { DocumentNode } from 'graphql'; import { Manager } from '@loona/core'; import { InnerActions, ScannedActions } from './actions'; export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; export interface QueryOptions extends Omit<WatchQueryOptions, 'query' | 'variables'> { } export interface MutationOptions extends Omit<CoreMutationOptions, 'mutation' | 'variables'> { } export declare type R = Record<string, any>; export interface TypedVariables<V> { variables?: V; } export declare class Loona { private apollo; private manager; private actions; private queue$; private direct$; constructor(apollo: Apollo, manager: Manager, actions: InnerActions, scannedActions: ScannedActions, errorHandler: ErrorHandler); query<T, V = any>(query: DocumentNode, variables?: V, options?: QueryOptions): QueryRef<T, V>; query<T, V = any>(options: WatchQueryOptions & TypedVariables<V>): QueryRef<T, V>; mutate<T, V = R>(mutation: DocumentNode, variables?: V, options?: MutationOptions): Observable<FetchResult<T>>; mutate<T, V = R>(options: CoreMutationOptions<T, V>): Observable<FetchResult<T>>; dispatch(action: any): void; extract<T = any>(): T; reset(): void; restore(state: any): void; }