//Example 1:
// Define new global class used in all views
Ext.define('MyApp.util.Utilities', {
singleton: true,
SomeValue: 1,
SomeText: 'First'
});
//override global instance with new values
MyApp.util.Utilities.SomeValue = 5;
MyApp.util.Utilities.SomeText = 'Hello World!';
//Example2 :
Ext.define('MyApp.config.Runtime',{
singleton : true,
config : {
myLastCustomer : 0 // initialize to 0
},
statics : {
user : 'Raja',
count: 0,
getCount:function () {
return this.count;
},
increment:function () {
this.count++;
}
},
constructor : function(config){
this.initConfig(config);
var statics = this.statics();
console.log('USER:'+statics.user);
}
});
//App defined here
Ext.application({
name : 'MyFiddle',
requires : ['MyApp.config.Runtime',
'MyApp.util.Utilities'], // Don't forget to require your class
// we can also define global variables which are used throughout the app
globals:{
myURL:'http://example.com',
myName: 'Global Var'
},
launch : function() {
console.log('global var old value:'+ MyApp.util.Utilities.SomeValue);
// Setting count value
MyApp.config.Runtime.count = 10;
console.log("Count after increment is " + MyApp.config.Runtime.count);
MyApp.util.Utilities.SomeValue = 2; //variables in singleton are auto static.
console.log('MyFiddle', 'Global Var new value:'+ MyApp.util.Utilities.SomeValue);
// access global var's
var somevalue = MyApp.util.Utilities.SomeValue;
var sometext = MyApp.util.Utilities.SomeText;
var someurl = MyFiddle.app.globals.myURL;
var somename = MyFiddle.app.globals.myName;
var str = 'SomeValue: '+somevalue+' <br/> SomeText: '+sometext+'<br/> myURL: '+
someurl+'<br/> myName:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.