import { DataModel } from './data-model';
export class ItemFetchState {
  constructor(data, isPending = false, error) {
    this.beforeFetch = () => new ItemFetchState(this.data, true, undefined);
    this.afterFetch = (response) => new ItemFetchState(DataModel.decode(response), false, undefined);
    this.afterFetchError = (error) => new ItemFetchState(this.data, false, error);
    this.data = data;
    this.error = error;
    this.isPending = isPending;
  }
}
ItemFetchState.init = () => new ItemFetchState();
