mirror of
https://github.com/google/blockly.git
synced 2026-01-16 05:17:09 +01:00
Remove the unnecessary construction of new services.
This commit is contained in:
@@ -55,10 +55,10 @@ blocklyApp.AppView = ng.core
|
||||
`,
|
||||
directives: [blocklyApp.ToolboxView, blocklyApp.WorkspaceView],
|
||||
pipes: [blocklyApp.TranslatePipe],
|
||||
// ClipboardService declared here so that all components are using the same
|
||||
// instance of the clipboard.
|
||||
// The clipboard and utils services are declared here, so that all
|
||||
// components in the application use the same instance of the service.
|
||||
// https://www.sitepoint.com/angular-2-components-providers-classes-factories-values/
|
||||
providers: [blocklyApp.ClipboardService]
|
||||
providers: [blocklyApp.ClipboardService, blocklyApp.UtilsService]
|
||||
})
|
||||
.Class({
|
||||
constructor: function() {}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
blocklyApp.ClipboardService = ng.core
|
||||
.Class({
|
||||
constructor: function() {
|
||||
blocklyApp.debug && console.log('Clipboard service constructed');
|
||||
this.clipboardBlockXml_ = null;
|
||||
this.clipboardBlockSuperiorConnection_ = null;
|
||||
this.clipboardBlockNextConnection_ = null;
|
||||
|
||||
@@ -62,8 +62,7 @@ blocklyApp.FieldView = ng.core
|
||||
</li>
|
||||
`,
|
||||
inputs: ['field', 'level', 'index', 'parentId'],
|
||||
pipes: [blocklyApp.TranslatePipe],
|
||||
providers: [blocklyApp.TreeService, blocklyApp.UtilsService]
|
||||
pipes: [blocklyApp.TranslatePipe]
|
||||
})
|
||||
.Class({
|
||||
constructor: [blocklyApp.UtilsService, function(_utilsService) {
|
||||
|
||||
@@ -105,13 +105,14 @@ blocklyApp.ToolboxTreeView = ng.core
|
||||
}), blocklyApp.FieldView],
|
||||
inputs: [
|
||||
'block', 'displayBlockMenu', 'level', 'index', 'tree', 'noCategories'],
|
||||
pipes: [blocklyApp.TranslatePipe],
|
||||
providers: [blocklyApp.TreeService, blocklyApp.UtilsService]
|
||||
pipes: [blocklyApp.TranslatePipe]
|
||||
})
|
||||
.Class({
|
||||
constructor: [blocklyApp.ClipboardService, blocklyApp.TreeService,
|
||||
blocklyApp.UtilsService,
|
||||
function(_clipboardService, _treeService, _utilsService) {
|
||||
constructor: [
|
||||
blocklyApp.ClipboardService, blocklyApp.TreeService, blocklyApp.UtilsService,
|
||||
function(_clipboardService, _treeService, _utilsService) {
|
||||
// ClipboardService and UtilsService are app-wide singleton services.
|
||||
// TreeService is from the parent ToolboxView component.
|
||||
this.infoBlocks = Object.create(null);
|
||||
this.clipboardService = _clipboardService;
|
||||
this.treeService = _treeService;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
/**
|
||||
* @fileoverview Angular2 Service that handles all tree keyboard navigation.
|
||||
* A separate TreeService is constructed for each tree in the application.
|
||||
*
|
||||
* @author madeeha@google.com (Madeeha Ghori)
|
||||
*/
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Angular2 Service with functions required by multiple
|
||||
* components.
|
||||
* @fileoverview Angular2 utility service for multiple components. All
|
||||
* functions in this service should be stateless, since this is a singleton
|
||||
* service that is used for the entire application.
|
||||
*
|
||||
* @author madeeha@google.com (Madeeha Ghori)
|
||||
*/
|
||||
|
||||
@@ -28,6 +30,7 @@ var blocklyApp = {};
|
||||
blocklyApp.UtilsService = ng.core
|
||||
.Class({
|
||||
constructor: function() {
|
||||
blocklyApp.debug && console.log('Utils service constructed');
|
||||
},
|
||||
generateUniqueId: function() {
|
||||
return 'blockly-' + Blockly.genUid();
|
||||
|
||||
@@ -117,11 +117,12 @@ blocklyApp.WorkspaceTreeView = ng.core
|
||||
[level]="level">
|
||||
</tree-view>
|
||||
`,
|
||||
directives: [ng.core.forwardRef(
|
||||
function() { return blocklyApp.WorkspaceTreeView; }), blocklyApp.FieldView],
|
||||
directives: [ng.core.forwardRef(function() {
|
||||
return blocklyApp.WorkspaceTreeView;
|
||||
}), blocklyApp.FieldView],
|
||||
inputs: ['block', 'isTopBlock', 'topBlockIndex', 'level', 'parentId'],
|
||||
pipes: [blocklyApp.TranslatePipe],
|
||||
providers: [blocklyApp.TreeService, blocklyApp.UtilsService],
|
||||
providers: [blocklyApp.TreeService],
|
||||
})
|
||||
.Class({
|
||||
constructor: [
|
||||
|
||||
Reference in New Issue
Block a user