import Model from "./Model" ; import Store from "./Store" ; import ModelResponse , { Callback } from "./ModelResponse" ; export default class StoreFetch < T extends Model > { store : Store < T > ; constructor ( store ) { this . store = store ; } fetch = async ( url , callback ? , store = this . store ) : Promise < ModelResponse < T > > => { const response = await store . http . get ( url ) ; return new ModelResponse < T > ( this . store . model , response , callback ) ; } ; index = async ( url , callback ? ) : Promise < T [ ] > => { const response = await this . fetch ( url , callback ) ; return response . asArray ; } ; get = async ( url , callback ? ) : Promise < T > => { const response = await this . fetch ( url , callback ) ; return response . asInstance ; } ; foreign = async ( store , url , callback ? ) : Promise < Model [ ] > => { const response = await this . fetch ( url , callback , store ) ; return response . asArray ; } ; }