UNPKG

owl-bt

Version:

owl-bt is editor for Behavior trees. It has been inspired by Unreal engine behavior trees in a way, that it supports special node items like decorators and services. This makes trees smaller and much more readable.

35 lines (27 loc) 781 B
'use strict'; (function() { const focusNodeEventName = 'tree-focus-focus-node'; /** * Enables views to subscribe for node focus requests. * View should move its displaying area to specified node on receiving this request */ class TreeFocus { constructor($rootScope) { this._$rootScope = $rootScope; } /** * subscribe listener * @param {scope} scope * @param {Function} callback - fun(node) */ subscribe(scope, callback) { var handler = this._$rootScope.$on(focusNodeEventName, (e, n) => callback(n)); scope.$on('$destroy', handler); } focusNode(node) { this._$rootScope.$emit(focusNodeEventName, node); } } angular.module('editorApp') .service('TreeFocus', TreeFocus); })();