import { createMiniApp , AppOptions , AppInstance , attachLogic } from '@goldfishjs/reactive-connect' ; import AppStore from '../store/AppStore' ; param storeClass param appOptions param options export default function createApp < G , S extends AppStore > ( storeClass , appOptions = { } , options ? ) { attachLogic < 'onLaunch' , Required < AppOptions < G , S > > [ 'onLaunch' ] > ( appOptions , 'onLaunch' , 'after' , async function ( this , options ) { const store = this . store ! ; store . isInitLoading = true ; const app = getApp ( ) ; store . watch ( ( ) => store . globalErrorInPromise , error => { const onError = ( app as any ) . onError ; if ( error && onError ) { onError ( error ) ; } } , { immediate : true , } ) ; await store . waitForInitDataReady ( ) ; try { await store . fetchInitData ( ) ; } catch ( e ) { throw e ; } finally { store . isInitLoading = false ; } } ) ; return createMiniApp < G , S > ( storeClass , appOptions , { ... options , afterCreateStore : ( view , store ) => { if ( options && options . afterCreateStore ) { options . afterCreateStore ( view , store ) ; } } , } ) ; }