How to use stateConfig method in Best

Best JavaScript code snippet using best

StateManager.js

Source:StateManager.js Github

copy

Full Screen

1/**2* @author Richard Davey <rich@photonstorm.com>3* @copyright 2016 Photon Storm Ltd.4* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}5*/6/**7* The State Manager is responsible for loading, setting up and switching game states.8*9* @class Phaser.StateManager10* @constructor11* @param {Phaser.Game} game - A reference to the currently running game.12*/13Phaser.StateManager = function (game, stateConfig)14{15 this.game = game;16 // Everything kept in here17 this.keys = {};18 this.states = [];19 // Only active states are kept in here20 this.active = [];21 this._pending = [];22 if (stateConfig)23 {24 if (Array.isArray(stateConfig))25 {26 for (var i = 0; i < stateConfig.length; i++)27 {28 // The i === 0 part just starts the first State given29 this._pending.push({ index: i, key: 'default', state: stateConfig[i], autoStart: (i === 0) });30 }31 }32 else33 {34 this._pending.push({ index: 0, key: 'default', state: stateConfig, autoStart: true });35 }36 }37};38Phaser.StateManager.prototype = {39 /**40 * The Boot handler is called by Phaser.Game when it first starts up.41 * The renderer is available by now.42 *43 * @method Phaser.StateManager#boot44 * @private45 */46 boot: function ()47 {48 // this.game.onPause.add(this.pause, this);49 // this.game.onResume.add(this.resume, this);50 console.log('StateManager.boot');51 for (var i = 0; i < this._pending.length; i++)52 {53 var entry = this._pending[i];54 this.add(entry.key, entry.state, entry.autoStart);55 }56 // Clear the pending list57 this._pending = [];58 },59 getKey: function (key, stateConfig)60 {61 if (!key) { key = 'default'; }62 if (stateConfig instanceof Phaser.State)63 {64 key = stateConfig.settings.key;65 }66 else if (typeof stateConfig === 'object' && stateConfig.hasOwnProperty('key'))67 {68 key = stateConfig.key;69 }70 // By this point it's either 'default' or extracted from the State71 if (this.keys.hasOwnProperty(key))72 {73 throw new Error('Cannot add a State with duplicate key: ' + key);74 }75 else76 {77 return key;78 }79 },80 /**81 * Adds a new State into the StateManager. You must give each State a unique key by which you'll identify it.82 * The State can be either a Phaser.State object (or an object that extends it), a plain JavaScript object or a function.83 * If a function is given a new state object will be created by calling it.84 *85 * @method Phaser.StateManager#add86 * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".87 * @param {Phaser.State|object|function} state - The state you want to switch to.88 * @param {boolean} [autoStart=false] - If true the State will be started immediately after adding it.89 */90 add: function (key, stateConfig, autoStart)91 {92 if (autoStart === undefined) { autoStart = false; }93 // if not booted, then put state into a holding pattern94 if (!this.game.isBooted)95 {96 this._pending.push({ index: this._pending.length, key: key, state: stateConfig, autoStart: autoStart });97 console.log('StateManager not yet booted, adding to list', this._pending.length);98 return;99 }100 key = this.getKey(key, stateConfig);101 var newState;102 if (stateConfig instanceof Phaser.State)103 {104 console.log('StateManager.add from instance', key);105 newState = this.createStateFromInstance(key, stateConfig);106 }107 else if (typeof stateConfig === 'object')108 {109 console.log('StateManager.add from object', key);110 stateConfig.key = key;111 newState = this.createStateFromObject(key, stateConfig);112 }113 else if (typeof stateConfig === 'function')114 {115 console.log('StateManager.add from function', key);116 newState = this.createStateFromFunction(key, stateConfig);117 }118 this.keys[key] = newState;119 this.states.push(newState);120 // window.console.dir(newState);121 if (autoStart || newState.settings.active)122 {123 if (this.game.isBooted)124 {125 this.start(key);126 }127 else128 {129 this._start.push(key);130 }131 }132 return newState;133 },134 createStateFromInstance: function (key, newState)135 {136 newState.game = this.game;137 newState.settings.key = key;138 newState.sys.init();139 if (this.game.renderType === Phaser.WEBGL)140 {141 this.createStateFrameBuffer(newState);142 }143 return newState;144 },145 createStateFromObject: function (key, stateConfig)146 {147 var newState = new Phaser.State(stateConfig);148 newState.game = this.game;149 newState.sys.init();150 if (this.game.renderType === Phaser.WEBGL)151 {152 this.createStateFrameBuffer(newState);153 }154 // Extract callbacks or set NOOP155 if (stateConfig.hasOwnProperty('init'))156 {157 newState.init = stateConfig.init;158 }159 if (stateConfig.hasOwnProperty('preload'))160 {161 newState.preload = stateConfig.preload;162 }163 if (stateConfig.hasOwnProperty('create'))164 {165 newState.create = stateConfig.create;166 }167 if (stateConfig.hasOwnProperty('shutdown'))168 {169 newState.shutdown = stateConfig.shutdown;170 }171 newState.preUpdate = (stateConfig.hasOwnProperty('preUpdate')) ? stateConfig.preUpdate : Phaser.NOOP;172 newState.update = (stateConfig.hasOwnProperty('update')) ? stateConfig.update : Phaser.NOOP;173 newState.postUpdate = (stateConfig.hasOwnProperty('postUpdate')) ? stateConfig.postUpdate : Phaser.NOOP;174 newState.render = (stateConfig.hasOwnProperty('render')) ? stateConfig.render : Phaser.NOOP;175 return newState;176 },177 createStateFromFunction: function (key, state)178 {179 var newState = new state();180 if (newState instanceof Phaser.State)181 {182 return this.createStateFromInstance(key, newState);183 }184 else185 {186 newState.game = this.game;187 newState.settings = new Phaser.State.Settings(newState, key);188 newState.sys = new Phaser.State.Systems(newState);189 newState.sys.init();190 if (this.game.renderType === Phaser.WEBGL)191 {192 this.createStateFrameBuffer(newState);193 }194 // Default required functions195 if (!newState.preUpdate)196 {197 newState.preUpdate = Phaser.NOOP;198 }199 if (!newState.update)200 {201 newState.update = Phaser.NOOP;202 }203 if (!newState.postUpdate)204 {205 newState.postUpdate = Phaser.NOOP;206 }207 if (!newState.render)208 {209 newState.render = Phaser.NOOP;210 }211 return newState;212 }213 },214 createStateFrameBuffer: function (newState)215 {216 var x = newState.settings.x;217 var y = newState.settings.y;218 if (newState.settings.width === -1)219 {220 newState.settings.width = this.game.width;221 }222 if (newState.settings.height === -1)223 {224 newState.settings.height = this.game.height;225 }226 var width = newState.settings.width;227 var height = newState.settings.height;228 newState.sys.fbo = this.game.renderer.createFBO(newState, x, y, width, height);229 },230 getState: function (key)231 {232 return this.keys[key];233 },234 getStateIndex: function (state)235 {236 return this.states.indexOf(state);237 },238 getActiveStateIndex: function (state)239 {240 for (var i = 0; i < this.active.length; i++)241 {242 if (this.active[i].state === state)243 {244 return this.active[i].index;245 }246 }247 return -1;248 },249 isActive: function (key)250 {251 var state = this.getState(key);252 return (state && state.settings.active && this.active.indexOf(state) !== -1);253 },254 start: function (key)255 {256 // if not booted, then put state into a holding pattern257 if (!this.game.isBooted)258 {259 console.log('StateManager not yet booted, setting autoStart on pending list');260 for (var i = 0; i < this._pending.length; i++)261 {262 var entry = this._pending[i];263 if (entry.key === key)264 {265 entry.autoStart = true;266 }267 }268 return;269 }270 var state = this.getState(key);271 if (state)272 {273 // Already started? Nothing more to do here ...274 if (this.isActive(key))275 {276 return;277 }278 state.settings.active = true;279 // + arguments280 if (state.init)281 {282 state.init.call(state);283 }284 if (state.preload)285 {286 state.sys.load.reset(true);287 state.preload.call(state, this.game);288 // Is the loader empty?289 if (state.sys.load.totalQueuedFiles() === 0 && state.sys.load.totalQueuedPacks() === 0)290 {291 // console.log('empty queue');292 this.startCreate(state);293 }294 else295 {296 // console.log('load start');297 // Start the loader going as we have something in the queue298 // state.load.onLoadComplete.addOnce(this.loadComplete, this, 0, state);299 state.sys.load.start();300 }301 }302 else303 {304 // console.log('no preload');305 // No preload? Then there was nothing to load either306 this.startCreate(state);307 }308 }309 },310 loadComplete: function (state)311 {312 // console.log('loadComplete');313 // Make sure to do load-update one last time before state is set to _created314 if (state.hasOwnProperty('loadUpdate'))315 {316 state.loadUpdate.call(state);317 }318 this.startCreate(state);319 },320 startCreate: function (state)321 {322 if (state.create)323 {324 state.create.call(state);325 }326 // Insert at the correct index, or it just all goes wrong :)327 var i = this.getStateIndex(state);328 this.active.push({ index: i, state: state });329 // Sort the 'active' array based on the index property330 this.active.sort(this.sortStates.bind(this));331 state.sys.updates.running = true;332 state.sys.mainloop.start();333 },334 pause: function (key)335 {336 var index = this.getActiveStateIndex(key);337 if (index > -1)338 {339 var state = this.getState(key);340 state.settings.active = false;341 this.active.splice(index, 1);342 this.active.sort(this.sortStates.bind(this));343 }344 },345 sortStates: function (stateA, stateB)346 {347 // Sort descending348 if (stateA.index < stateB.index)349 {350 return -1;351 }352 else if (stateA.index > stateB.index)353 {354 return 1;355 }356 else357 {358 return 0;359 }360 },361 // See if we can reduce this down to just update and render362 step: function (timestamp)363 {364 for (var i = 0; i < this.active.length; i++)365 {366 var state = this.active[i].state;367 if (state.sys.mainloop.running)368 {369 state.sys.mainloop.step(timestamp);370 }371 }372 },373 /*374 preUpdate: function ()375 {376 for (var i = 0; i < this.active.length; i++)377 {378 var state = this.active[i].state;379 for (var c = 0; c < state.sys.children.list.length; c++)380 {381 state.sys.children.list[c].preUpdate();382 }383 state.preUpdate();384 }385 },386 update: function ()387 {388 for (var i = 0; i < this.active.length; i++)389 {390 var state = this.active[i].state;391 // Invoke State Main Loop here - updating all of its systems (tweens, physics, etc)392 // This shouldn't be called if the State is still loading393 // Have a State.STATUS const in the Settings, dictating what is going on394 for (var c = 0; c < state.sys.children.list.length; c++)395 {396 var child = state.sys.children.list[c];397 if (child.exists)398 {399 child.update();400 }401 }402 state.update();403 }404 },405 postUpdate: function ()406 {407 for (var i = 0; i < this.active.length; i++)408 {409 var state = this.active[i].state;410 for (var c = 0; c < state.sys.children.list.length; c++)411 {412 state.sys.children.list[c].postUpdate();413 }414 state.postUpdate();415 }416 },417 render: function ()418 {419 for (var i = 0; i < this.active.length; i++)420 {421 var state = this.active[i].state;422 // Can put all kinds of other checks in here, like MainLoop, FPS, etc.423 if (!state.settings.visible || state.sys.color.alpha === 0 || state.sys.children.list.length === 0)424 {425 continue;426 }427 this.game.renderer.render(state);428 }429 },430 */431 renderChildren: function (renderer, state, interpolationPercentage)432 {433 // Populates the display list434 for (var c = 0; c < state.sys.children.list.length; c++)435 {436 var child = state.sys.children.list[c];437 child.render(renderer, child, interpolationPercentage);438 }439 }...

Full Screen

Full Screen

GlobalStateManager.js

Source:GlobalStateManager.js Github

copy

Full Screen

1/**2* @author Richard Davey <rich@photonstorm.com>3* @copyright 2016 Photon Storm Ltd.4* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}5*/6var CONST = require('../const');7var NOOP = require('../utils/NOOP');8var State = require('./State');9var Systems = require('./Systems');10var GetObjectValue = require('../utils/object/GetObjectValue');11var EventDispatcher = require('../events/EventDispatcher');12var Rectangle = require('../geom/rectangle/Rectangle');13var CanvasPool = require('../dom/CanvasPool');14var CanvasInterpolation = require('../dom/CanvasInterpolation');15var GetContext = require('../canvas/GetContext');16/**17* The State Manager is responsible for loading, setting up and switching game states.18*19* @class Phaser.GlobalStateManager20* @constructor21* @param {Phaser.Game} game - A reference to the currently running game.22*/23var GlobalStateManager = function (game, stateConfig)24{25 this.game = game;26 // Everything kept in here27 this.keys = {};28 this.states = [];29 // Only active states are kept in here30 this.active = [];31 this._pending = [];32 if (stateConfig)33 {34 if (Array.isArray(stateConfig))35 {36 for (var i = 0; i < stateConfig.length; i++)37 {38 // The i === 0 part just starts the first State given39 this._pending.push({40 index: i,41 key: 'default',42 state: stateConfig[i],43 autoStart: (i === 0),44 data: {}45 });46 }47 }48 else49 {50 this._pending.push({51 index: 0,52 key: 'default',53 state: stateConfig,54 autoStart: true,55 data: {}56 });57 }58 }59};60GlobalStateManager.prototype.constructor = GlobalStateManager;61GlobalStateManager.prototype = {62 /**63 * The Boot handler is called by Phaser.Game when it first starts up.64 * The renderer is available by now.65 *66 * @method Phaser.GlobalStateManager#boot67 * @private68 */69 boot: function ()70 {71 for (var i = 0; i < this._pending.length; i++)72 {73 var entry = this._pending[i];74 this.add(entry.key, entry.state, entry.autoStart);75 }76 // Clear the pending list77 this._pending = [];78 },79 // private80 getKey: function (key, stateConfig)81 {82 if (!key) { key = 'default'; }83 if (stateConfig instanceof State)84 {85 key = stateConfig.settings.key;86 }87 else if (typeof stateConfig === 'object' && stateConfig.hasOwnProperty('key'))88 {89 key = stateConfig.key;90 }91 // By this point it's either 'default' or extracted from the State92 if (this.keys.hasOwnProperty(key))93 {94 throw new Error('Cannot add a State with duplicate key: ' + key);95 }96 else97 {98 return key;99 }100 },101 /**102 * Adds a new State into the GlobalStateManager. You must give each State a unique key by which you'll identify it.103 * The State can be either a Phaser.State object (or an object that extends it), a plain JavaScript object or a function.104 * If a function is given a new state object will be created by calling it.105 *106 * @method Phaser.GlobalStateManager#add107 * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".108 * @param {Phaser.State|object|function} state - The state you want to switch to.109 * @param {boolean} [autoStart=false] - If true the State will be started immediately after adding it.110 */111 add: function (key, stateConfig, autoStart)112 {113 if (autoStart === undefined) { autoStart = false; }114 // if not booted, then put state into a holding pattern115 if (!this.game.isBooted)116 {117 this._pending.push({118 index: this._pending.length,119 key: key,120 state: stateConfig,121 autoStart: autoStart122 });123 console.log('GlobalStateManager not yet booted, adding to list', this._pending.length);124 return;125 }126 key = this.getKey(key, stateConfig);127 // console.log('GlobalStateManager.add', key, stateConfig, autoStart);128 var newState;129 if (stateConfig instanceof State)130 {131 // console.log('GlobalStateManager.add from instance:', key);132 newState = this.createStateFromInstance(key, stateConfig);133 }134 else if (typeof stateConfig === 'object')135 {136 // console.log('GlobalStateManager.add from object:', key);137 stateConfig.key = key;138 newState = this.createStateFromObject(key, stateConfig);139 }140 else if (typeof stateConfig === 'function')141 {142 // console.log('GlobalStateManager.add from function:', key);143 newState = this.createStateFromFunction(key, stateConfig);144 }145 this.keys[key] = newState;146 this.states.push(newState);147 if (autoStart || newState.settings.active)148 {149 if (this.game.isBooted)150 {151 this.start(key);152 }153 else154 {155 this._start.push(key);156 }157 }158 return newState;159 },160 createStateFromInstance: function (key, newState)161 {162 newState.settings.key = key;163 newState.sys.init(this.game);164 this.createStateDisplay(newState);165 return newState;166 },167 createStateFromObject: function (key, stateConfig)168 {169 var newState = new State(stateConfig);170 newState.sys.init(this.game);171 this.createStateDisplay(newState);172 return this.setupCallbacks(newState, stateConfig);173 },174 createStateFromFunction: function (key, state)175 {176 var newState = new state();177 if (newState instanceof State)178 {179 return this.createStateFromInstance(key, newState);180 }181 else182 {183 newState.sys = new Systems(newState);184 newState.sys.init(this.game);185 this.createStateDisplay(newState);186 // Default required functions187 if (!newState.init)188 {189 newState.init = NOOP;190 }191 if (!newState.preload)192 {193 newState.preload = NOOP;194 }195 if (!newState.create)196 {197 newState.create = NOOP;198 }199 if (!newState.shutdown)200 {201 newState.shutdown = NOOP;202 }203 if (!newState.update)204 {205 newState.update = NOOP;206 }207 if (!newState.render)208 {209 newState.render = NOOP;210 }211 return newState;212 }213 },214 setupCallbacks: function (state, stateConfig)215 {216 if (stateConfig === undefined) { stateConfig = state; }217 // Extract callbacks or set NOOP218 state.init = GetObjectValue(stateConfig, 'init', NOOP);219 state.preload = GetObjectValue(stateConfig, 'preload', NOOP);220 state.create = GetObjectValue(stateConfig, 'create', NOOP);221 state.shutdown = GetObjectValue(stateConfig, 'shutdown', NOOP);222 // Game Loop level callbacks223 state.update = GetObjectValue(stateConfig, 'update', NOOP);224 state.render = GetObjectValue(stateConfig, 'render', NOOP);225 return state;226 },227 createStateDisplay: function (state)228 {229 // console.log('createStateDisplay', state.settings.key);230 var settings = state.sys.settings;231 // var x = settings.x;232 // var y = settings.y;233 var width = settings.width;234 var height = settings.height;235 var config = this.game.config;236 if (config.renderType === CONST.CANVAS)237 {238 if (settings.renderToTexture)239 {240 // console.log('renderToTexture', width, height);241 state.sys.canvas = CanvasPool.create(state, width, height);242 state.sys.context = GetContext(state.sys.canvas);243 // Pixel Art mode?244 if (config.pixelArt)245 {246 CanvasInterpolation.setCrisp(state.sys.canvas);247 }248 }249 else250 {251 // console.log('using game canvas');252 state.sys.mask = new Rectangle(0, 0, width, height);253 state.sys.canvas = this.game.canvas;254 state.sys.context = this.game.context;255 }256 }257 else if (config.renderType === CONST.WEBGL)258 {259 // state.sys.fbo = this.game.renderer.createFBO(state, x, y, width, height);260 }261 },262 getState: function (key)263 {264 return this.keys[key];265 },266 getStateIndex: function (state)267 {268 return this.states.indexOf(state);269 },270 getActiveStateIndex: function (state)271 {272 var index = -1;273 for (var i = 0; i < this.active.length; i++)274 {275 if (this.active[i].state === state)276 {277 index = this.active[i].index;278 }279 }280 return index;281 },282 isActive: function (key)283 {284 var state = this.getState(key);285 return (state && state.settings.active && this.active.indexOf(state) !== -1);286 },287 start: function (key, data)288 {289 if (data === undefined) { data = {}; }290 // console.log('start:', key);291 // console.dir(data);292 // if not booted, then put state into a holding pattern293 if (!this.game.isBooted)294 {295 // console.log('GlobalStateManager not yet booted, setting autoStart on pending list');296 for (var i = 0; i < this._pending.length; i++)297 {298 var entry = this._pending[i];299 if (entry.key === key)300 {301 entry.autoStart = true;302 entry.data = data;303 }304 }305 return;306 }307 var state = this.getState(key);308 if (state)309 {310 // Already started? Nothing more to do here ...311 if (this.isActive(key))312 {313 return;314 }315 state.settings.active = true;316 state.settings.data = data;317 var loader = state.sys.load;318 // Files payload?319 if (loader && Array.isArray(state.sys.settings.files))320 {321 loader.reset();322 if (loader.loadArray(state.sys.settings.files))323 {324 loader.events.once('LOADER_COMPLETE_EVENT', this.payloadComplete.bind(this));325 loader.start();326 }327 else328 {329 this.bootState(state);330 }331 }332 else333 {334 this.bootState(state);335 }336 }337 },338 payloadComplete: function (event)339 {340 var state = event.loader.state;341 // console.log('payloadComplete', state.sys.settings.key);342 this.bootState(state);343 },344 bootState: function (state)345 {346 // console.log('bootState', state.sys.settings.key);347 if (state.init)348 {349 state.init.call(state, state.sys.settings.data);350 }351 var loader = state.sys.load;352 353 loader.reset();354 if (state.preload)355 {356 state.preload(this.game);357 // Is the loader empty?358 if (loader.list.size === 0)359 {360 this.create(state);361 }362 else363 {364 // Start the loader going as we have something in the queue365 loader.events.once('LOADER_COMPLETE_EVENT', this.loadComplete.bind(this));366 loader.start();367 }368 }369 else370 {371 // No preload? Then there was nothing to load either372 this.create(state);373 }374 },375 loadComplete: function (event)376 {377 var state = event.loader.state;378 // console.log('loadComplete', state.sys.settings.key);379 this.create(state);380 },381 create: function (state)382 {383 // console.log('create', state.sys.settings.key);384 // Insert at the correct index, or it just all goes wrong :)385 var i = this.getStateIndex(state);386 // console.log('create.index', state.sys.settings.key, i);387 this.active.push({ index: i, state: state });388 // Sort the 'active' array based on the index property389 this.active.sort(this.sortStates);390 state.sys.updates.running = true;391 if (state.create)392 {393 state.create(state.sys.settings.data);394 }395 },396 pause: function (key)397 {398 var index = this.getActiveStateIndex(this.getState(key));399 if (index > -1)400 {401 var state = this.getState(key);402 state.settings.active = false;403 this.active.splice(index, 1);404 this.active.sort(this.sortStates);405 }406 },407 sortStates: function (stateA, stateB)408 {409 // console.log('sortStates', stateA.state.sys.settings.key, stateA.index, stateB.state.sys.settings.key, stateB.index);410 // Sort descending411 if (stateA.index < stateB.index)412 {413 return -1;414 }415 else if (stateA.index > stateB.index)416 {417 return 1;418 }419 else420 {421 return 0;422 }423 }424};...

Full Screen

Full Screen

angular_ui_router.js

Source:angular_ui_router.js Github

copy

Full Screen

1/*2 * Copyright 2014 The Closure Compiler Authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16/**17 * @fileoverview Externs for ui-router.18 *19 * API Reference: http://angular-ui.github.io/ui-router/site/#/api/ui.router20 *21 * @externs22 */23/**24 * Suppresses the compiler warning when multiple externs files declare the25 * ui namespace.26 * @suppress {duplicate, const}27 * @const28 */29var ui = {};30/**31 * @const32 */33ui.router = {};34/** @typedef {!Object} */35ui.router.StateParams;36/** @typedef {!ui.router.StateParams} */37ui.router.$stateParams;38/**39 * This is the state configuration object that is getting passed to40 * $stateProvider.state() method.41 * @record42 */43ui.router.StateConfig = function() {};44/** @type {boolean|undefined} */45ui.router.StateConfig.prototype.abstract;46/** @type {string|!angular.Injectable|undefined} */47ui.router.StateConfig.prototype.controller;48/** @type {string|undefined} */49ui.router.StateConfig.prototype.controllerAs;50/** @type {!angular.Injectable|undefined} */51ui.router.StateConfig.prototype.controllerProvider;52/** @type {!Object|undefined} */53ui.router.StateConfig.prototype.data;54/** @type {!angular.Injectable|undefined} */55ui.router.StateConfig.prototype.onEnter;56/** @type {!angular.Injectable|undefined} */57ui.router.StateConfig.prototype.onExit;58/** @type {!Object|undefined} */59ui.router.StateConfig.prototype.params;60/** @type {boolean|undefined} */61ui.router.StateConfig.prototype.reloadOnSearch;62/** @type {!Object<string, (!angular.Injectable|string)>|undefined} */63ui.router.StateConfig.prototype.resolve;64/** @type {string|undefined} */65ui.router.StateConfig.prototype.template;66/** @type {string|undefined} */67ui.router.StateConfig.prototype.templateUrl;68/** @type {function(...): (!angular.$q.Promise<string>|string)|undefined} */69ui.router.StateConfig.prototype.templateProvider;70/** @type {string|undefined} */71ui.router.StateConfig.prototype.url;72/** @type {!Object<string, !ui.router.State>|undefined} */73ui.router.StateConfig.prototype.views;74/**75 * This is the object that the ui-router passes to callback functions listening76 * on ui router events such as `$stateChangeStart` or77 * `$stateChangeError` as the `toState` and `fromState`.78 * Example:79 * $rootScope.$on('$stateChangeStart', function(80 * event, toState, toParams, fromState, fromParams){ ... });81 * TODO(dtarasiuk): remove field duplication when @extends works for @record82 * @record83 */84ui.router.State = function() {};85/** @type {string} */86ui.router.State.prototype.name;87/** @type {boolean|undefined} */88ui.router.State.prototype.abstract;89/** @type {string|!angular.Injectable|undefined} */90ui.router.State.prototype.controller;91/** @type {string|undefined} */92ui.router.State.prototype.controllerAs;93/** @type {!Function|undefined} */94ui.router.State.prototype.controllerProvider;95/** @type {!Object|undefined} */96ui.router.State.prototype.data;97/** @type {!angular.Injectable|undefined} */98ui.router.State.prototype.onEnter;99/** @type {!angular.Injectable|undefined} */100ui.router.State.prototype.onExit;101/** @type {!Object|undefined} */102ui.router.State.prototype.params;103/** @type {boolean|undefined} */104ui.router.State.prototype.reloadOnSearch;105/** @type {!Object<string, (!angular.Injectable|string)>|undefined} */106ui.router.State.prototype.resolve;107/** @type {string|undefined} */108ui.router.State.prototype.template;109/** @type {string|undefined} */110ui.router.State.prototype.templateUrl;111/** @type {function(): string|undefined} */112ui.router.State.prototype.templateProvider;113/** @type {string|undefined} */114ui.router.State.prototype.url;115/** @type {!Object<string, !ui.router.State>|undefined} */116ui.router.State.prototype.views;117/** @record */118ui.router.$state = function() {};119/** @type {!ui.router.State} */120ui.router.$state.prototype.current;121/** @type {!Object} */122ui.router.$state.prototype.params;123/** @type {!Object} */124ui.router.$state.prototype.options;125/** @type {?angular.$q.Promise} */126ui.router.$state.prototype.transition;127/**128 * @param {VALUE=} opt_stateName129 * @return {RESULT}130 *131 * @template VALUE132 * @template RESULT :=133 * cond(isUnknown(VALUE),134 * type('Array', 'ui.router.State'),135 * 'ui.router.State')136 * =:137 */138ui.router.$state.prototype.get = function(opt_stateName) {};139/** @record */140ui.router.StateOptions = function() {};141/** @type {boolean|string|undefined} */142ui.router.StateOptions.prototype.location;143/** @type {boolean|undefined} */144ui.router.StateOptions.prototype.inherit;145/** @type {!ui.router.State|undefined} */146ui.router.StateOptions.prototype.relative;147/** @type {boolean|undefined} */148ui.router.StateOptions.prototype.notify;149/** @type {boolean|undefined} */150ui.router.StateOptions.prototype.reload;151/**152 * @param {string|!ui.router.State} to153 * @param {?ui.router.StateParams=} opt_toParams154 * @param {!ui.router.StateOptions=} opt_options155 * @return {!angular.$q.Promise}156 */157ui.router.$state.prototype.go = function(to, opt_toParams, opt_options) {};158/** @record */159ui.router.HrefOptions = function() {};160/** @type {boolean|undefined} */161ui.router.HrefOptions.prototype.lossy;162/** @type {boolean|undefined} */163ui.router.HrefOptions.prototype.inherit;164/** @type {!ui.router.State|undefined} */165ui.router.HrefOptions.prototype.relative;166/** @type {boolean|undefined} */167ui.router.HrefOptions.prototype.absolute;168/**169 * @param {string|!ui.router.State} stateOrName170 * @param {!ui.router.StateParams=} opt_params171 * @param {!ui.router.HrefOptions=} opt_options172 * @return {string} compiled state url173 */174ui.router.$state.prototype.href = function(175 stateOrName, opt_params, opt_options) {};176/**177 * @param {string|!ui.router.State} stateOrName178 * @param {!ui.router.StateParams=} opt_params179 */180ui.router.$state.prototype.includes = function(stateOrName, opt_params) {};181/**182 * @param {string|!ui.router.State} stateOrName183 * @param {!ui.router.StateParams=} opt_params184 * @return {boolean}185 */186ui.router.$state.prototype.is = function(stateOrName, opt_params) {};187/**188 * @param {string|!ui.router.State=} opt_stateOrName189 * @return {!angular.$q.Promise}190 */191ui.router.$state.prototype.reload = function(opt_stateOrName) {};192/**193 * @param {string|!ui.router.State} to194 * @param {!ui.router.StateParams=} opt_toParams195 * @param {!ui.router.StateOptions=} opt_options196 */197ui.router.$state.prototype.transitionTo = function(198 to, opt_toParams, opt_options) {};199/**200 * @interface201 */202ui.router.$urlRouter = function() {};203/**204 * @param {*=} opt_event205 * @return {void}206 */207ui.router.$urlRouter.prototype.sync = function(opt_event) {};208/**209 * @param {boolean=} opt_enabled210 * @return {function(...)}211 */212ui.router.$urlRouter.prototype.listen = function(opt_enabled) {};213/**214 * @interface215 */216ui.router.$urlMatcherFactory = function() {};217/**218 * @param {boolean} value219 * @return {boolean}220 */221ui.router.$urlMatcherFactory.prototype.strictMode = function(value) {};222/**223 * @interface224 * @param {!ui.router.$urlMatcherFactory} $urlMatcherFactory225 */226ui.router.$urlRouterProvider = function($urlMatcherFactory) {};227/**228 * @param {string|RegExp} url229 * @param {string|function(...)|Array<!Object>} route230 */231ui.router.$urlRouterProvider.prototype.when = function(url, route) {};232/**233 * @param {string|function(...)} path234 */235ui.router.$urlRouterProvider.prototype.otherwise = function(path) {};236/**237 * @param {function(...)} rule238 */239ui.router.$urlRouterProvider.prototype.rule = function(rule) {};240/**241 * @param {boolean=} opt_defer242 * @return {void}243 */244ui.router.$urlRouterProvider.prototype.deferIntercept = function(opt_defer) {};245/**246 * @interface247 * @param {!ui.router.$urlRouterProvider} $urlRouterProvider248 * @param {!ui.router.$urlMatcherFactory} $urlMatcherFactory249 * @param {!angular.$locationProvider} $locationProvider250 */251ui.router.$stateProvider = function(252 $urlRouterProvider, $urlMatcherFactory, $locationProvider) {};253/**254 * @param {!string} name255 * @param {!ui.router.StateConfig} stateConfig256 * @return {!ui.router.$stateProvider}257 */258ui.router.$stateProvider.prototype.state = function(name, stateConfig) {};259/**260 * @param {!string} name261 * @param {(function(!ui.router.State, !Function):262 * Object<!ui.router.StateConfig>)=} opt_decoratorFn263 * @return {!ui.router.$stateProvider}264 */265ui.router.$stateProvider.prototype.decorator = function(...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestBuy = require("./bestBuy.js");2var bb = new bestBuy();3bb.stateConfig("CA");4bb.stateConfig("NY");5bb.stateConfig("TX");6module.exports = function BestBuy() {7 this.stateConfig = function(state) {8 console.log("State Configured: " + state);9 };10};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stateConfig = require('./BestPractice').stateConfig;2var state = {3 data: {4 },5 onEnter: function() {6 console.log('entering state1');7 },8 onExit: function() {9 console.log('exiting state1');10 },11 on: {12 }13};14stateConfig(state);15console.log(state);16var stateConfig = require('./BestPractice').stateConfig;17var state = {18 data: {19 },20 onEnter: function() {21 console.log('entering state1');22 },23 onExit: function() {24 console.log('exiting state1');25 },26 on: {27 }28};29stateConfig(state);30console.log(state);31state.onEnter();32state.onExit();33var stateConfig = require('./BestPractice').stateConfig;34var state = {35 data: {36 },37 onEnter: function() {38 console.log('entering state1');39 },40 onExit: function() {41 console.log('exiting state1');42 },43 on: {44 }45};46stateConfig(state);47console.log(state);48state.onEnter();49state.onExit();50state.on.EVENT1();51var stateConfig = require('./BestPractice').stateConfig;52var state = {53 data: {54 },55 onEnter: function() {56 console.log('entering state1');57 },58 onExit: function() {59 console.log('exiting state1');60 },61 on: {62 }63};64stateConfig(state);65console.log(state);66state.onEnter();67state.onExit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var stateConfig = require('best-practice').stateConfig;2var state = {3};4stateConfig(state);5module.exports = state;6var stateConfig = require('best-practice').stateConfig;7var state = {8};9stateConfig(state);10module.exports = state;11var stateConfig = require('best-practice').stateConfig;12var state = {13};14stateConfig(state);15module.exports = state;16var stateConfig = require('best-practice').stateConfig;17var state = {18};19stateConfig(state);20module.exports = state;21var stateConfig = require('best-practice').stateConfig;22var state = {23};24stateConfig(state);25module.exports = state;26var stateConfig = require('best-practice').stateConfig;27var state = {28};29stateConfig(state);30module.exports = state;31var stateConfig = require('best-practice').stateConfig;32var state = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestState = require('./BestState');2var state = new BestState();3var data = [ { state: 'CA', value: 10 }, { state: 'CA', value: 20 }, { state: 'CA', value: 30 }, { state: 'NY', value: 10 }, { state: 'NY', value: 20 }, { state: 'NY', value: 30 } ];4state.stateConfig(data);5console.log(state.getBestState());6var BestState = function () {7 var data;8 var bestState;9 this.stateConfig = function (data) {10 var states = {};11 for (var i = 0; i < data.length; i++) {12 if (states[data[i].state]) {13 states[data[i].state].total += data[i].value;14 states[data[i].state].count++;15 } else {16 states[data[i].state] = {17 };18 }19 }20 var bestState;21 for (var state in states) {22 if (typeof best

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestBuy = require('./bestbuy');2const bestbuy = new BestBuy('your_api_key');3const state = 'CA';4bestbuy.stateConfig(state).then((data) => {5 console.log(`BestBuy has ${data.stores} stores in ${state}`);6});7const request = require('request-promise');8class BestBuy {9 constructor(apiKey) {10 this.apiKey = apiKey;11 }12 stateConfig(state) {13 const options = {14 };15 return request(options)16 .then((data) => {17 return {18 };19 });20 }21}22module.exports = BestBuy;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful