UNPKG

@magicbell/core

Version:

Official MagicBell API wrapper

32 lines (31 loc) 988 B
import PaginatedStore from './PaginatedStore.js'; import { Identifiable } from './Store.js'; /** * A store that keep tracks of pagination as well. * * @example * const store = new RemoteStore(); * store.push(model); */ export default abstract class RemoteStore<T extends Identifiable> extends PaginatedStore<T> { abstract repo: any; xhrFetchState: 'idle' | 'pending' | 'success' | 'failure'; /** * Fetch items from the API server. The pagination data is also * updated. By default the array of items is not reset. * * @param queryParams Parameters to send to the API. * @param options.reset Reset the store. */ fetch(queryParams: any, options?: { reset: boolean; }): Promise<void>; /** * Fetch the next page of items. * * @param queryParams Parameters to send to the API. */ fetchNextPage(queryParams?: {}): Promise<void>; abstract create(data: any): any; abstract set(json: any): any; }