halfnelson / svelte-native

Svelte controlling native components via Nativescript
MIT License
1.82k stars 78 forks source link

fix: Live-sync reloading entire view tree #349

Closed CatchABus closed 1 year ago

CatchABus commented 1 year ago

Right now, all components are reloaded during HMR on android platform. That is because NativeScript is resetting activity content on live-sync. The culprit: https://github.com/NativeScript/NativeScript/blob/main/packages/core/ui/frame/index.android.ts#L105

To counter this for the time being, we have to override global.__onLiveSyncCore like all flavors do.

I copied the one from NativeScript-Vue which for some kind of reason updates CSS state. https://github.com/nativescript-vue/nativescript-vue/blob/main/src/nativescript/index.ts#L12

@farfromrefug I thought it'd be suitable to put this in index file but let me know if you have any better ideas.