MCPcopy
hub / github.com/jabbany/CommentCoreLibrary / registerObject

Function registerObject

src/scripting/api/Runtime/Runtime.ts:168–192  ·  view source on GitHub ↗
(object:RegisterableObject)

Source from the content-addressed store, hash-verified

166 * @param {RegisterableObject} object - object to be registered.
167 */
168 export function registerObject(object:RegisterableObject):void{
169 if (!object.getId) {
170 __trace('Cannot register object without getId method.','warn');
171 return;
172 }
173 if (!Runtime.hasObject(object.getId())) {
174 _registeredObjects[object.getId()] = object;
175 __pchannel('Runtime:RegisterObject', {
176 'id': object.getId(),
177 'data': object.serialize()
178 });
179 __schannel("object::(" + object.getId() + ")", (payload:any) => {
180 if (payload.hasOwnProperty('type') &&
181 payload.type === 'event') {
182 _dispatchEvent(object.getId(), payload.event, payload.data);
183 }
184 });
185 objCount++;
186 return;
187 } else {
188 __trace('Attempted to re-register object or id collision @ ' +
189 object.getId(), 'warn');
190 return;
191 }
192 }
193
194 /**
195 * De-Registers an object from the runtime. This not only removes the object

Callers

nothing calls this directly

Calls 8

__traceFunction · 0.85
__pchannelFunction · 0.85
__schannelFunction · 0.85
_dispatchEventFunction · 0.85
hasObjectMethod · 0.80
hasOwnPropertyMethod · 0.80
getIdMethod · 0.65
serializeMethod · 0.65

Tested by

no test coverage detected