0

Inside one my tabview tabs I have a 'Logout' button with this

var application = require("application");
application.run({ moduleName: "app-login" });

However I get:

RangeError: Maximum call stack size exceeded

when the code is executed. Ultimately I'm trying to get back to the login screen when the user needs to logout, in full screen (i.e not within the tab). The architecture of the application is based similar to the tabview-template example, with frames for each tab.

Any help much appreciated!

Devil10
  • 1,853
  • 1
  • 18
  • 22
Chris Bekas
  • 27
  • 1
  • 6
  • It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit. refer https://stackoverflow.com/a/6095695/704008 – Pranav Singh Aug 21 '18 at 05:51

2 Answers2

0

I may be misunderstanding your architecture, but I don't think calling the bootstrap function application.run({ moduleName: "app-login" }); more than once in the app's lifecycle is valid as the app is already running (regardless the screen it's on).

Eddy Verbruggen
  • 3,550
  • 1
  • 15
  • 27
  • Thanks Eddy, so what is the recommended architecture to have a login screen and be able to go back to it when using tabviews? – Chris Bekas Aug 21 '18 at 11:22
  • @ChrisBekas I highly recommend you to use Angular. You could map an app route to the login screen. Then, you can just navigate to that route. – Sebastiandg7 Aug 21 '18 at 14:48
  • @SebastianDuque unfortunately I'm using Nativescript core. So you can do this in Angular but not in nativescript core? Thanks! – Chris Bekas Aug 21 '18 at 22:39
0

Indeed the application.run() is the method that bootstraps your app. You shouldn't call it twice.

The nested frames feature isn't officially supported and isn't documented, but it's possible in NativeScript core. The reason it's not yet official is due to some unexpected side effects with ActionBars and such. In your scenario you should simply get the correct Frame and call navigate() on it. I created a simple playground example here - https://play.nativescript.org/?template=play-tsc&id=tq6B2K

The key in this example is to assign an id to each Frame in your xml, so that you can use the getFrameById() method to find the correct Frame in the hierarchy.

Also, note that I have set actionBarHidden to true on the page with the tabs. If this is not set, you would see two nested ActionBars.

Martin Yankov
  • 351
  • 3
  • 7