0

If I create a context and add some layout and surfaces, but later want to restart the entire app is there a way to do this?

Is there a method on the Engine?

Basically I am asking if there is something that is the opposite of Engine.createContext ?

Dan Baker
  • 1,757
  • 3
  • 21
  • 36
  • 1
    Currently, there isn't any way since the `contexts` variable is closured over inside the Engine singleton. There may be some `eval` hackery that could accomplish this, but I'm not certain (plus, it'd be hella ugly). You may want to submit this as an issue here, https://github.com/Famous/core/issues/new . Be sure to explain why you need this functionality (I'm assuming you want this for testing purposes) – Andrew De Andrade Jun 26 '14 at 20:21
  • Thanks, my purpose is to reapply a changing config object that is read in to describe properites of surfaces, and transition etc. It would be great to re init the app when this config changes, unless it is better to keep each surface referenced and apply changes directly to the affected surface? – Dan Baker Jun 26 '14 at 20:28
  • I think there may be much better ways to accomplish what you want, but you should provide more details on this issue here: https://github.com/Famous/core/issues/51 – Andrew De Andrade Jun 26 '14 at 22:30

1 Answers1

1

You can use a RenderController to add/remove content from the render-tree:

// import dependencies
var Engine = require('famous/core/Engine');
var RenderNode = require('famous/core/RenderNode');
var RenderController = require('famous/views/RenderController');

// create context & render-controller
var context = Engine.createContext();
var renderController = new RenderController();
context.add(renderController);

function restart() {

    // create content you want to show
    var content = new AppView();

    // Show content
    var renderNode = new RenderNode(content);
    renderController.show(renderNode, {duration: 0});
}
restart();
IjzerenHein
  • 2,690
  • 1
  • 17
  • 13