Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

solution of application resume problem #78

Closed
@blackss2

Description

@blackss2
  • I am new at nodejs and nativescript, so I am sorry I cannot have much time to contribute.

As you know, if you do not use process kill, resume your application make [View already has parent error].
I guess root of this problem is alive time of application view and vue instance.

[Process Started] -> AppView Dead / VueInstance Dead
[App Started]   -> AppView Alive / VueInstance Alive
[App Destroyed]  -> AppView Dead / VueInstance Alive
[App Started]   -> AppView Alive / VueInstance Alive
[App Destroyed]  -> AppView Dead / VueInstance Alive
[Process Closed]  -> AppView Dead / VueInstance Dead

When you re-start app, your vue instance is alive inside of application.start({ create(){HERE} });
So self.$el.nativeView will return View that should be dead at destroyed time but alived due to VueInstance reference.

Here is my simple boiler plate patch.
It add main_vm and clear it at application.on(exitEvent).
So your vue instance will replaced with another root vue instance.
NOW YOU CAN USE android.app.Service.extend FOR CREATING BACKGROUND SERVICE
OLD WAY TO CLEAN nativescript-vue - PROCESS KILL, IS KILL SERVICE TOO

Vue$3.$start({template:`<page>...</page>`});
// make start for changing main_vm when application destroyedVue$3.$start=function(comp){// main_vm is current main activity vue instanceletmain_vm;constapplication=require("tns-core-modules/application");// clear old view and destroy closing main_vmapplication.on(application.exitEvent,function(args){main_vm.$destroy();main_vm=undefined;});// make application independent with initial vmapplication.start({create(){main_vm=newVue$3(comp);letel=main_vm.$start();// Call mountComponent in the create callback when the IOS app loop has started// https://github.com/rigor789/nativescript-vue/issues/24mountComponent(main_vm,el,undefined);constpage=isPage(main_vm.$el) ?main_vm.$el.nativeView :newui_page.Page();if(!isPage(main_vm.$el)){page.content=main_vm.$el.nativeView;}returnpage}});}// remove application.start({create(){}}) from mount for making application.start independent with initial vmconstmount=function(el,hydrating){if(this.__is_root__){}else{mountComponent(this,el,hydrating);}};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp