rdkcentral / Lightning-SDK

SDK for Lightning framework
Apache License 2.0
130 stars 69 forks source link

The router is not destroying a page when it gets unloaded via a step back in history #125

Closed achille1789 closed 4 years ago

achille1789 commented 4 years ago

Hi, I put together a mini app to try to clear completely, from the memory/history, a page when the user navigate back, using settings: lazyDestroy false and destroyOnHistoryBack true. I have a router with 2 pages. The default one is Home and the second one is Article. The article page has a dynamic route: article/:id. From Home I go in the Article page and show its id, then I go back in Home with Router.step(-1) and then I go in Article again but this time I am passing a different id on the route. I am expecting to see shown only the second id but the first one is still there. What am I doing wrong? Thanks in advance.

Here is my settings.json { "appSettings": { "stage": { "clearColor": "0x00000000", "useImageWorker": true }, "debug": false }, "platformSettings": { "path": "./static", "log": true, "showVersion": true, "showFps": false, "numberNavigation": false, "router": { "destroyOnHistoryBack": true, "lazyDestroy": false, "gcOnUnload": true } } }

Here is my App.js `import { Lightning, Utils, Router } from 'wpe-lightning-sdk'

import routes from './routes';

export default class App extends Lightning.Component { static getFonts() { return [{ family: 'Regular', url: Utils.asset('fonts/Roboto-Regular.ttf') }] }

static _template() { return { Background: { w: 1920, h: 1080, color: 0xfffbb03b, src: Utils.asset('images/background.png'), }, Pages: { w: 1920, h: 1080, forceZIndexContext: true, }, } }

_captureLeft() { Router.step(-1); }

_setup() { Router.startRouter(routes, this); }

} `

Here is my routes.js import Home from './Home'; import Article from './Article'; export default { root: 'home', routes: [ { path: 'home', component: Home, }, { path: 'article/:id', component: Article, }, ], };

Here is my Article.js `import {Lightning} from 'wpe-lightning-sdk'; export default class Article extends Lightning.Component { static _template() { return { rect: true, color: 0xff000000, w: 1920, h: 1080, Debug: { text: { text: '', }, }, }; }

set id(v) {
    this.tag('Debug').text.text = this.tag('Debug').text.text + v;
}

} `

Here is a screenshot of the first time in the article (with url path) Screenshot 2020-09-30 at 10 20 12

Here is a screenshot of the second time in the article (with url path) Screenshot 2020-09-30 at 10 20 20

achille1789 commented 4 years ago

With the new sdk version 3.0.0 this problem is not longer reproducible.