From 8d3554b46b849aa64eef8cf050a388b2cc7174fd Mon Sep 17 00:00:00 2001 From: "Theunis J. Botha" Date: Tue, 7 Sep 2021 06:01:07 +0200 Subject: [PATCH] input system --- dist/r3.js | 306 +++++------------- package.json | 2 +- r3.php | 14 +- src/r3/r3-event.js | 23 +- src/r3/r3-r3.js | 4 +- src/r3/r3-system/r3-system-input.js | 228 +++---------- src/r3/r3-system/r3-system-linking.js | 44 +-- src/r3/r3-system/r3-system-socket.js | 5 +- src/r3/r3-system/r3-system-test.js | 5 +- src/r3/r3-system/r3-system.js | 8 +- .../generated_event_listeners_start.template | 10 +- .../generated_event_listeners_stop.template | 12 +- ...ated_static_event_listeners_start.template | 10 +- ...rated_static_event_listeners_stop.template | 11 +- src/templates/static_start.template | 1 + src/templates/token.db | 2 - version | 2 +- 17 files changed, 201 insertions(+), 486 deletions(-) diff --git a/dist/r3.js b/dist/r3.js index c814628..6822da0 100644 --- a/dist/r3.js +++ b/dist/r3.js @@ -1,12 +1,12 @@ class R3 { - static version = '2.0.163'; - static compileDate = '2021 Sep 06 - 12:30:38 pm'; + static version = '2.0.176'; + static compileDate = '2021 Sep 06 - 13:04:25 pm'; } /** Started=false - Subscriptions=[] + Subscriptions={} **/ @@ -24,7 +24,7 @@ class System { options.started = false; } if (typeof options.subscriptions === 'undefined') { - options.subscriptions = []; + options.subscriptions = {}; } Object.assign(this, options); @@ -36,7 +36,7 @@ class System { } System.Started = false; -System.Subscriptions = []; +System.Subscriptions = {}; class Event { @@ -226,6 +226,7 @@ class Event { } Event.Subscriptions[eventId][subscriptionId] = callback; + } else { Event.Subscriptions[eventId] = {}; Event.Subscriptions[eventId][subscriptionId] = callback; @@ -253,6 +254,8 @@ class Event { if (listeners.length === 0) { delete Event.Subscriptions[eventId]; } + + return true; } }(eventId, subscriptionId), @@ -282,12 +285,11 @@ Event.OBJECT_INITIALIZED = 0x10; Event.PAUSE = 0x11; Event.RESTART = 0x12; Event.START = 0x13; -Event.TEST_EVENT = 0x14; -Event.TOUCH_CANCEL = 0x15; -Event.TOUCH_END = 0x16; -Event.TOUCH_MOVE = 0x17; -Event.TOUCH_START = 0x18; -Event.MAX_EVENTS = 0x19; +Event.TOUCH_CANCEL = 0x14; +Event.TOUCH_END = 0x15; +Event.TOUCH_MOVE = 0x16; +Event.TOUCH_START = 0x17; +Event.MAX_EVENTS = 0x18; Event.GetEventName = function(eventId) { @@ -311,11 +313,10 @@ Event.GetEventName = function(eventId) { case 0x11 : return 'pause'; case 0x12 : return 'restart'; case 0x13 : return 'start'; - case 0x14 : return 'test_event'; - case 0x15 : return 'touch_cancel'; - case 0x16 : return 'touch_end'; - case 0x17 : return 'touch_move'; - case 0x18 : return 'touch_start'; + case 0x14 : return 'touch_cancel'; + case 0x15 : return 'touch_end'; + case 0x16 : return 'touch_move'; + case 0x17 : return 'touch_start'; default : throw new Error('Event type not defined : ' + eventId); } @@ -1578,12 +1579,12 @@ class Utils { Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -1619,8 +1620,6 @@ class Utils { - Stop() Stops the system by removing these subscriptions to events - Event.TEST_EVENT - **/ class SystemInput extends System { @@ -1647,13 +1646,6 @@ class SystemInput extends System { */ start() { - this.subscriptions.push( - new Event.Subscribe( - Event.TEST_EVENT, - this.OnTestEvent - ) - ); - console.log('Test for custom start before'); this.started = true; @@ -1668,16 +1660,6 @@ class SystemInput extends System { */ stop() { - this.subscriptions = this.subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TEST_EVENT) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); - this.started = false; console.log('Stopped transient system: SystemInput'); @@ -1690,74 +1672,54 @@ class SystemInput extends System { */ static Start() { - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_START, - SystemInput.OnTouchStart - ) + SystemInput.Subscriptions['TOUCH_START'] = new Event.Subscribe( + Event.TOUCH_START, + SystemInput.OnTouchStart ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_END, - SystemInput.OnTouchEnd - ) + SystemInput.Subscriptions['TOUCH_END'] = new Event.Subscribe( + Event.TOUCH_END, + SystemInput.OnTouchEnd ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_MOVE, - SystemInput.OnTouchMove - ) + SystemInput.Subscriptions['TOUCH_MOVE'] = new Event.Subscribe( + Event.TOUCH_MOVE, + SystemInput.OnTouchMove ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_CANCEL, - SystemInput.OnTouchCancel - ) + SystemInput.Subscriptions['TOUCH_CANCEL'] = new Event.Subscribe( + Event.TOUCH_CANCEL, + SystemInput.OnTouchCancel ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.KEYBOARD_DOWN, - SystemInput.OnKeyboardDown - ) + SystemInput.Subscriptions['KEYBOARD_DOWN'] = new Event.Subscribe( + Event.KEYBOARD_DOWN, + SystemInput.OnKeyboardDown ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.KEYBOARD_UP, - SystemInput.OnKeyboardUp - ) + SystemInput.Subscriptions['KEYBOARD_UP'] = new Event.Subscribe( + Event.KEYBOARD_UP, + SystemInput.OnKeyboardUp ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_DOWN, - SystemInput.OnMouseDown - ) + SystemInput.Subscriptions['MOUSE_DOWN'] = new Event.Subscribe( + Event.MOUSE_DOWN, + SystemInput.OnMouseDown ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_UP, - SystemInput.OnMouseUp - ) + SystemInput.Subscriptions['MOUSE_UP'] = new Event.Subscribe( + Event.MOUSE_UP, + SystemInput.OnMouseUp ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_MOVE, - SystemInput.OnMouseMove - ) + SystemInput.Subscriptions['MOUSE_MOVE'] = new Event.Subscribe( + Event.MOUSE_MOVE, + SystemInput.OnMouseMove ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_WHEEL, - SystemInput.OnMouseWheel - ) + SystemInput.Subscriptions['MOUSE_WHEEL'] = new Event.Subscribe( + Event.MOUSE_WHEEL, + SystemInput.OnMouseWheel ); SystemInput.Started = true; @@ -1772,105 +1734,35 @@ class SystemInput extends System { */ static Stop() { - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_START) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_START'].remove(); + delete SystemInput.Subscriptions['TOUCH_START']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_END) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_END'].remove(); + delete SystemInput.Subscriptions['TOUCH_END']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_MOVE) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_MOVE'].remove(); + delete SystemInput.Subscriptions['TOUCH_MOVE']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_CANCEL) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_CANCEL'].remove(); + delete SystemInput.Subscriptions['TOUCH_CANCEL']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.KEYBOARD_DOWN) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['KEYBOARD_DOWN'].remove(); + delete SystemInput.Subscriptions['KEYBOARD_DOWN']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.KEYBOARD_UP) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['KEYBOARD_UP'].remove(); + delete SystemInput.Subscriptions['KEYBOARD_UP']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_DOWN) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_DOWN'].remove(); + delete SystemInput.Subscriptions['MOUSE_DOWN']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_UP) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_UP'].remove(); + delete SystemInput.Subscriptions['MOUSE_UP']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_MOVE) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_MOVE'].remove(); + delete SystemInput.Subscriptions['MOUSE_MOVE']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_WHEEL) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_WHEEL'].remove(); + delete SystemInput.Subscriptions['MOUSE_WHEEL']; SystemInput.Started = false; @@ -1878,16 +1770,6 @@ class SystemInput extends System { } - /** - * OnTestEvent() - * - Listens to events of type Event.TEST_EVENT and executes this function. - * @param data (The event data passed as argument - typically an R3Object) - * @return null - */ - OnTestEvent(data) { - - } - /** * OnTouchStart() * - Listens to events of type Event.TOUCH_START and executes this function. @@ -1998,12 +1880,12 @@ class SystemInput extends System { Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -2092,18 +1974,14 @@ class SystemLinking extends System { */ static Start(options) { - SystemLinking.Subscriptions.push( - new Event.Subscribe( - Event.OBJECT_CREATED, - SystemLinking.OnObjectCreated - ) + SystemLinking.Subscriptions['OBJECT_CREATED'] = new Event.Subscribe( + Event.OBJECT_CREATED, + SystemLinking.OnObjectCreated ); - SystemLinking.Subscriptions.push( - new Event.Subscribe( - Event.INSTANCE_CREATED, - SystemLinking.OnInstanceCreated - ) + SystemLinking.Subscriptions['INSTANCE_CREATED'] = new Event.Subscribe( + Event.INSTANCE_CREATED, + SystemLinking.OnInstanceCreated ); SystemLinking.Started = true; @@ -2119,25 +1997,11 @@ class SystemLinking extends System { */ static Stop(options) { - SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.OBJECT_CREATED) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemLinking.Subscriptions['OBJECT_CREATED'].remove(); + delete SystemLinking.Subscriptions['OBJECT_CREATED']; - SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.INSTANCE_CREATED) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemLinking.Subscriptions['INSTANCE_CREATED'].remove(); + delete SystemLinking.Subscriptions['INSTANCE_CREATED']; SystemLinking.Started = false; @@ -2175,12 +2039,12 @@ class SystemLinking extends System { Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -2302,12 +2166,12 @@ class SystemSocket extends System { Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: diff --git a/package.json b/package.json index f1de5b4..a662fe8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "r3", - "version" : "2.0.163", + "version" : "2.0.176", "description": "", "private": true, "dependencies": { diff --git a/r3.php b/r3.php index ebe3e3e..0123d20 100755 --- a/r3.php +++ b/r3.php @@ -665,7 +665,8 @@ function generateEventListenersStart($file, $tokens) $methodName = to_camel_case_from_upper_underscore($methodName); - $updates = str_replace('EVENT_NAME', $item, $template); + $updates = str_replace('FULL_EVENT_NAME', $item, $template); + $updates = str_replace('EVENT_NAME', $eventName, $updates); $updates = str_replace('CALL_BACK', $methodName, $updates); $updated .= $updates; @@ -693,7 +694,9 @@ function generateEventListenersStop($file, $tokens) foreach ($store as $item) { $item = trim($item); - $updates = str_replace('EVENT_NAME', $item, $template); + $eventName = preg_replace('/Event./', '', $item); + + $updates = str_replace('EVENT_NAME', $eventName, $template); $updated .= $updates; } @@ -727,7 +730,8 @@ function generateStaticEventListenersStart($file, $tokens) $methodName = to_camel_case_from_upper_underscore($methodName); - $updates = str_replace('EVENT_NAME', $item, $template); + $updates = str_replace('FULL_EVENT_NAME', $item, $template); + $updates = str_replace('EVENT_NAME', $eventName, $updates); $updates = str_replace('CALL_BACK', $methodName, $updates); $updated .= $updates; @@ -755,7 +759,9 @@ function generateStaticEventListenersStop($file, $tokens) foreach ($store as $item) { $item = trim($item); - $updates = str_replace('EVENT_NAME', $item, $template); + $eventName = preg_replace('/Event./', '', $item); + + $updates = str_replace('EVENT_NAME', $eventName, $template); $updated .= $updates; } diff --git a/src/r3/r3-event.js b/src/r3/r3-event.js index ad85c81..d6a546d 100644 --- a/src/r3/r3-event.js +++ b/src/r3/r3-event.js @@ -262,6 +262,7 @@ class Event { } Event.Subscriptions[eventId][subscriptionId] = callback; + } else { Event.Subscriptions[eventId] = {}; Event.Subscriptions[eventId][subscriptionId] = callback; @@ -289,6 +290,8 @@ class Event { if (listeners.length === 0) { delete Event.Subscriptions[eventId]; } + + return true; } }(eventId, subscriptionId), @@ -323,12 +326,11 @@ Event.OBJECT_INITIALIZED = 0x10; Event.PAUSE = 0x11; Event.RESTART = 0x12; Event.START = 0x13; -Event.TEST_EVENT = 0x14; -Event.TOUCH_CANCEL = 0x15; -Event.TOUCH_END = 0x16; -Event.TOUCH_MOVE = 0x17; -Event.TOUCH_START = 0x18; -Event.MAX_EVENTS = 0x19; +Event.TOUCH_CANCEL = 0x14; +Event.TOUCH_END = 0x15; +Event.TOUCH_MOVE = 0x16; +Event.TOUCH_START = 0x17; +Event.MAX_EVENTS = 0x18; Event.GetEventName = function(eventId) { @@ -352,11 +354,10 @@ Event.GetEventName = function(eventId) { case 0x11 : return 'pause'; case 0x12 : return 'restart'; case 0x13 : return 'start'; - case 0x14 : return 'test_event'; - case 0x15 : return 'touch_cancel'; - case 0x16 : return 'touch_end'; - case 0x17 : return 'touch_move'; - case 0x18 : return 'touch_start'; + case 0x14 : return 'touch_cancel'; + case 0x15 : return 'touch_end'; + case 0x16 : return 'touch_move'; + case 0x17 : return 'touch_start'; default : throw new Error('Event type not defined : ' + eventId); } diff --git a/src/r3/r3-r3.js b/src/r3/r3-r3.js index 917b0f4..dec6749 100644 --- a/src/r3/r3-r3.js +++ b/src/r3/r3-r3.js @@ -1,6 +1,6 @@ class R3 { - static version = '2.0.163'; - static compileDate = '2021 Sep 06 - 12:30:38 pm'; + static version = '2.0.176'; + static compileDate = '2021 Sep 06 - 13:04:25 pm'; } //GENERATED_IMPORTS_START diff --git a/src/r3/r3-system/r3-system-input.js b/src/r3/r3-system/r3-system-input.js index bdfe811..5d6a94e 100644 --- a/src/r3/r3-system/r3-system-input.js +++ b/src/r3/r3-system/r3-system-input.js @@ -12,12 +12,12 @@ const System = require('./r3-system.js'); Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -131,13 +131,6 @@ class SystemInput extends System { //GENERATED_START_METHOD_START //GENERATED_EVENT_LISTENERS_START_START - - this.subscriptions.push( - new Event.Subscribe( - Event.TEST_EVENT, - this.OnTestEvent - ) - ); //GENERATED_EVENT_LISTENERS_START_END //CUSTOM_BEFORE_SYSTEM_START_START @@ -163,15 +156,6 @@ class SystemInput extends System { //GENERATED_STOP_METHOD_START //GENERATED_EVENT_LISTENERS_STOP_START - this.subscriptions = this.subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TEST_EVENT) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); //GENERATED_EVENT_LISTENERS_STOP_END //CUSTOM_BEFORE_SYSTEM_STOP_START @@ -199,76 +183,56 @@ class SystemInput extends System { //GENERATED_STATIC_START_METHOD_START //GENERATED_STATIC_EVENT_LISTENERS_START_START - - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_START, - SystemInput.OnTouchStart - ) + SystemInput.Subscriptions['TOUCH_START'] = new Event.Subscribe( + Event.TOUCH_START, + SystemInput.OnTouchStart ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_END, - SystemInput.OnTouchEnd - ) + SystemInput.Subscriptions['TOUCH_END'] = new Event.Subscribe( + Event.TOUCH_END, + SystemInput.OnTouchEnd ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_MOVE, - SystemInput.OnTouchMove - ) + SystemInput.Subscriptions['TOUCH_MOVE'] = new Event.Subscribe( + Event.TOUCH_MOVE, + SystemInput.OnTouchMove ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.TOUCH_CANCEL, - SystemInput.OnTouchCancel - ) + SystemInput.Subscriptions['TOUCH_CANCEL'] = new Event.Subscribe( + Event.TOUCH_CANCEL, + SystemInput.OnTouchCancel ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.KEYBOARD_DOWN, - SystemInput.OnKeyboardDown - ) + SystemInput.Subscriptions['KEYBOARD_DOWN'] = new Event.Subscribe( + Event.KEYBOARD_DOWN, + SystemInput.OnKeyboardDown ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.KEYBOARD_UP, - SystemInput.OnKeyboardUp - ) + SystemInput.Subscriptions['KEYBOARD_UP'] = new Event.Subscribe( + Event.KEYBOARD_UP, + SystemInput.OnKeyboardUp ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_DOWN, - SystemInput.OnMouseDown - ) + SystemInput.Subscriptions['MOUSE_DOWN'] = new Event.Subscribe( + Event.MOUSE_DOWN, + SystemInput.OnMouseDown ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_UP, - SystemInput.OnMouseUp - ) + SystemInput.Subscriptions['MOUSE_UP'] = new Event.Subscribe( + Event.MOUSE_UP, + SystemInput.OnMouseUp ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_MOVE, - SystemInput.OnMouseMove - ) + SystemInput.Subscriptions['MOUSE_MOVE'] = new Event.Subscribe( + Event.MOUSE_MOVE, + SystemInput.OnMouseMove ); - SystemInput.Subscriptions.push( - new Event.Subscribe( - Event.MOUSE_WHEEL, - SystemInput.OnMouseWheel - ) + SystemInput.Subscriptions['MOUSE_WHEEL'] = new Event.Subscribe( + Event.MOUSE_WHEEL, + SystemInput.OnMouseWheel ); + //GENERATED_STATIC_EVENT_LISTENERS_START_END //CUSTOM_BEFORE_STATIC_SYSTEM_START_START @@ -294,106 +258,36 @@ class SystemInput extends System { //GENERATED_STATIC_STOP_METHOD_START //GENERATED_STATIC_EVENT_LISTENERS_STOP_START + SystemInput.Subscriptions['TOUCH_START'].remove(); + delete SystemInput.Subscriptions['TOUCH_START']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_START) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_END'].remove(); + delete SystemInput.Subscriptions['TOUCH_END']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_END) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_MOVE'].remove(); + delete SystemInput.Subscriptions['TOUCH_MOVE']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_MOVE) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['TOUCH_CANCEL'].remove(); + delete SystemInput.Subscriptions['TOUCH_CANCEL']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.TOUCH_CANCEL) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['KEYBOARD_DOWN'].remove(); + delete SystemInput.Subscriptions['KEYBOARD_DOWN']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.KEYBOARD_DOWN) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['KEYBOARD_UP'].remove(); + delete SystemInput.Subscriptions['KEYBOARD_UP']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.KEYBOARD_UP) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_DOWN'].remove(); + delete SystemInput.Subscriptions['MOUSE_DOWN']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_DOWN) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_UP'].remove(); + delete SystemInput.Subscriptions['MOUSE_UP']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_UP) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_MOVE'].remove(); + delete SystemInput.Subscriptions['MOUSE_MOVE']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_MOVE) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemInput.Subscriptions['MOUSE_WHEEL'].remove(); + delete SystemInput.Subscriptions['MOUSE_WHEEL']; - SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.MOUSE_WHEEL) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); //GENERATED_STATIC_EVENT_LISTENERS_STOP_END //CUSTOM_BEFORE_STATIC_SYSTEM_STOP_START @@ -412,22 +306,6 @@ class SystemInput extends System { //GENERATED_STATIC_METHODS_END //GENERATED_EVENT_LISTENER_METHODS_START - - /** - * OnTestEvent() - * - Listens to events of type Event.TEST_EVENT and executes this function. - * @param data (The event data passed as argument - typically an R3Object) - * @return null - */ - OnTestEvent(data) { - - //GENERATED_ON_TEST_EVENT_METHOD_START - //GENERATED_ON_TEST_EVENT_METHOD_END - - //CUSTOM_ON_TEST_EVENT_METHOD_START - //CUSTOM_ON_TEST_EVENT_METHOD_END - - } //GENERATED_EVENT_LISTENER_METHODS_END //GENERATED_STATIC_EVENT_LISTENER_METHODS_START diff --git a/src/r3/r3-system/r3-system-linking.js b/src/r3/r3-system/r3-system-linking.js index 0b0926d..71d463a 100644 --- a/src/r3/r3-system/r3-system-linking.js +++ b/src/r3/r3-system/r3-system-linking.js @@ -12,12 +12,12 @@ const System = require('./r3-system.js'); Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -177,20 +177,16 @@ class SystemLinking extends System { //GENERATED_STATIC_START_METHOD_START //GENERATED_STATIC_EVENT_LISTENERS_START_START - - SystemLinking.Subscriptions.push( - new Event.Subscribe( - Event.OBJECT_CREATED, - SystemLinking.OnObjectCreated - ) + SystemLinking.Subscriptions['OBJECT_CREATED'] = new Event.Subscribe( + Event.OBJECT_CREATED, + SystemLinking.OnObjectCreated ); - SystemLinking.Subscriptions.push( - new Event.Subscribe( - Event.INSTANCE_CREATED, - SystemLinking.OnInstanceCreated - ) + SystemLinking.Subscriptions['INSTANCE_CREATED'] = new Event.Subscribe( + Event.INSTANCE_CREATED, + SystemLinking.OnInstanceCreated ); + //GENERATED_STATIC_EVENT_LISTENERS_START_END //CUSTOM_BEFORE_STATIC_SYSTEM_START_START @@ -217,26 +213,12 @@ class SystemLinking extends System { //GENERATED_STATIC_STOP_METHOD_START //GENERATED_STATIC_EVENT_LISTENERS_STOP_START + SystemLinking.Subscriptions['OBJECT_CREATED'].remove(); + delete SystemLinking.Subscriptions['OBJECT_CREATED']; - SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.OBJECT_CREATED) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + SystemLinking.Subscriptions['INSTANCE_CREATED'].remove(); + delete SystemLinking.Subscriptions['INSTANCE_CREATED']; - SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(Event.INSTANCE_CREATED) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); //GENERATED_STATIC_EVENT_LISTENERS_STOP_END //CUSTOM_BEFORE_STATIC_SYSTEM_STOP_START diff --git a/src/r3/r3-system/r3-system-socket.js b/src/r3/r3-system/r3-system-socket.js index cd4ba6d..99dfa93 100644 --- a/src/r3/r3-system/r3-system-socket.js +++ b/src/r3/r3-system/r3-system-socket.js @@ -12,12 +12,12 @@ const System = require('./r3-system.js'); Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -176,6 +176,7 @@ class SystemSocket extends System { //GENERATED_STATIC_START_METHOD_START //GENERATED_STATIC_EVENT_LISTENERS_START_START + //GENERATED_STATIC_EVENT_LISTENERS_START_END //CUSTOM_BEFORE_STATIC_SYSTEM_START_START diff --git a/src/r3/r3-system/r3-system-test.js b/src/r3/r3-system/r3-system-test.js index 2b32692..1f8bf30 100644 --- a/src/r3/r3-system/r3-system-test.js +++ b/src/r3/r3-system/r3-system-test.js @@ -12,12 +12,12 @@ const System = require('./r3-system.js'); Inherited Properties: - started (Default value false) - - subscriptions (Default value []) + - subscriptions (Default value {}) Inherited Static Properties: - Started (Default value false) - - Subscriptions (Default value []) + - Subscriptions (Default value {}) Inherited Methods: @@ -175,6 +175,7 @@ class SystemTest extends System { //GENERATED_STATIC_START_METHOD_START //GENERATED_STATIC_EVENT_LISTENERS_START_START + //GENERATED_STATIC_EVENT_LISTENERS_START_END //CUSTOM_BEFORE_STATIC_SYSTEM_START_START diff --git a/src/r3/r3-system/r3-system.js b/src/r3/r3-system/r3-system.js index 3038aa8..1068a6a 100644 --- a/src/r3/r3-system/r3-system.js +++ b/src/r3/r3-system/r3-system.js @@ -5,12 +5,12 @@ const Utils = require('.././r3-utils'); CUSTOM_OPTIONS_START started=false - subscriptions=[] + subscriptions={} CUSTOM_OPTIONS_END CUSTOM_STATIC_OPTIONS_START Started=false - Subscriptions=[] + Subscriptions={} CUSTOM_STATIC_OPTIONS_END CUSTOM_EVENT_LISTENERS_START @@ -43,7 +43,7 @@ class System { options.started = false; } if (typeof options.subscriptions === 'undefined') { - options.subscriptions = []; + options.subscriptions = {}; } //GENERATED_OPTIONS_INIT_END @@ -81,7 +81,7 @@ class System { //GENERATED_STATIC_OPTIONS_INIT_START System.Started = false; -System.Subscriptions = []; +System.Subscriptions = {}; //GENERATED_STATIC_OPTIONS_INIT_END //CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START diff --git a/src/templates/generated_event_listeners_start.template b/src/templates/generated_event_listeners_start.template index 2df0e47..b193e84 100644 --- a/src/templates/generated_event_listeners_start.template +++ b/src/templates/generated_event_listeners_start.template @@ -1,7 +1,5 @@ - - this.subscriptions.push( - new Event.Subscribe( - EVENT_NAME, - this.CALL_BACK - ) + this.subscriptions['EVENT_NAME'] = new Event.Subscribe( + FULL_EVENT_NAME, + SYSTEM_NAME.CALL_BACK ); + diff --git a/src/templates/generated_event_listeners_stop.template b/src/templates/generated_event_listeners_stop.template index 4eaa969..6eab845 100644 --- a/src/templates/generated_event_listeners_stop.template +++ b/src/templates/generated_event_listeners_stop.template @@ -1,9 +1,3 @@ - this.subscriptions = this.subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(EVENT_NAME) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); + this.subscriptions['EVENT_NAME'].remove(); + delete this.subscriptions['EVENT_NAME']; + diff --git a/src/templates/generated_static_event_listeners_start.template b/src/templates/generated_static_event_listeners_start.template index f0b5ed3..25b05ed 100644 --- a/src/templates/generated_static_event_listeners_start.template +++ b/src/templates/generated_static_event_listeners_start.template @@ -1,7 +1,5 @@ - - SYSTEM_NAME.Subscriptions.push( - new Event.Subscribe( - EVENT_NAME, - SYSTEM_NAME.CALL_BACK - ) + SYSTEM_NAME.Subscriptions['EVENT_NAME'] = new Event.Subscribe( + FULL_EVENT_NAME, + SYSTEM_NAME.CALL_BACK ); + diff --git a/src/templates/generated_static_event_listeners_stop.template b/src/templates/generated_static_event_listeners_stop.template index d39a119..548541f 100644 --- a/src/templates/generated_static_event_listeners_stop.template +++ b/src/templates/generated_static_event_listeners_stop.template @@ -1,10 +1,3 @@ + SYSTEM_NAME.Subscriptions['EVENT_NAME'].remove(); + delete SYSTEM_NAME.Subscriptions['EVENT_NAME']; - SYSTEM_NAME.Subscriptions = SYSTEM_NAME.Subscriptions.reduce( - (result, subscription) => { - if (subscription.remove(EVENT_NAME) !== true) { - result.push(subscription); - } - return result; - }, - [] - ); diff --git a/src/templates/static_start.template b/src/templates/static_start.template index 9bb2a98..acbe0a9 100644 --- a/src/templates/static_start.template +++ b/src/templates/static_start.template @@ -1,5 +1,6 @@ //GENERATED_STATIC_EVENT_LISTENERS_START_START + //GENERATED_STATIC_EVENT_LISTENERS_START_END //CUSTOM_BEFORE_STATIC_SYSTEM_START_START diff --git a/src/templates/token.db b/src/templates/token.db index ce5482d..9fb7069 100644 --- a/src/templates/token.db +++ b/src/templates/token.db @@ -19,7 +19,6 @@ GENERATED_INDEX_BODY GENERATED_INHERITED GENERATED_METHOD_NAME_UPPERCASE_METHOD GENERATED_METHODS -GENERATED_ON_TEST_EVENT_METHOD GENERATED_OPTIONS_INIT GENERATED_START_METHOD GENERATED_STATIC_ASYNC_METHOD @@ -69,7 +68,6 @@ CUSTOM_INSTANCE_OPTIONS_MAPPING CUSTOM_LINKED_OBJECTS CUSTOM_METHOD_NAME_UPPERCASE_METHOD CUSTOM_METHODS -CUSTOM_ON_TEST_EVENT_METHOD CUSTOM_OPTIONS CUSTOM_OPTIONS_INIT CUSTOM_OUT_OF_CLASS_IMPLEMENTATION diff --git a/version b/version index 5166a2f..4b37297 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.0.163 \ No newline at end of file +2.0.176 \ No newline at end of file