Results 1 to 2 of 2

Thread: 'singleton' view

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    448

    Default 'singleton' view

    Hi all;
    in 1.x I had a single overlay used by my app to display stuff on lists clicks (I just changed its content on every click). in 1.x, the overlay was a global parameter. in 2.x with the new MVC structure, I created an overlay view. thing is, I only want one instance of this view and I want it to be shared by multiple views (again, showing/hiding it and updating its content when needed).
    what is the proper architectural approach for a thing like this?
    thanks.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Do somethign like this:

    Code:
    Ext.define('MyApp.view.Overlay', {
        extend    : 'Ext.Panel',
        xtype     : 'myapp-overlay',
        singleton : true,
    
        config : {
            centered : true,
            modal    : true,
            html     : 'Foo'
        }
    });
    
    Ext.application({
        name : 'MyApp',
    
        launch : function () {
    
            //needs to be added to viewport
            Ext.Viewport.add(MyApp.view.Overlay);
            //hide it or else it will show
            MyApp.view.Overlay.hide();
    
        }
    });
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •