import { createMiniPage , PageOptions , PageInstance , attachLogic } from '@goldfishjs/reactive-connect' ; import { silent } from '@goldfishjs/utils' ; import AppStore from '../store/AppStore' ; import PageStore from '../store/PageStore' ; param storeClass param pageOptions param options export default function createPage < AS extends AppStore , PS extends PageStore < AS > , D = any > ( storeClass , pageOptions = { } , options ? ) { attachLogic < 'onLoad' , Required < PageOptions < D , PS > > [ 'onLoad' ] > ( pageOptions , 'onLoad' , 'after' , async function ( this ) { const store = this . store ! ; store . isInitLoading = true ; await silent . async ( ( ) => store . appStore . waitForInitDataReady ( ) ) ( ) ; try { await store . fetchInitData ( ) ; } catch ( e ) { throw e ; } finally { store . isInitLoading = false ; } } ) ; return createMiniPage < AS , PS , D > ( storeClass , pageOptions , { ... options , afterCreateStore : ( view , store ) => { options && options . afterCreateStore && options . afterCreateStore ( view , store ) ; store . appStore = ( getApp ( ) as any ) . store ; } , } ) ; }