Deprecation of addHook and clearHooks

Device registration

Registering devices to the Cumulocity-IoT platform is one of its essentials. While bringing the UI in that area to the next level and migrating parts of it, we found two methods (addHook, clearHooks) that are completely unused in our code-base.

function addHook(injectionFunction) {
      return function () {
        const ix = registrationHooks.indexOf(injectionFunction);
        if (ix > -1) {
          registrationHooks.splice(ix, 1);

function clearHooks() {
      registrationHooks.length = 0;

When using addHook you can provide a method that would be invoked whenever a new registration to the platform happens. A “new registration” would be every creation of a managedObject while accepting the new device registration request.

The clearHooks method simply sets the length of added hooks to zero. Given checks .length > 0 will return false and therefore not run any code.

Why we are deprecating these methods?

In connection with scalability, we want to avoid wildcard-subscriptions as much as possible. Deprecating these methods is one step in that direction. Already mentioned: our internal code-base is not using addHook and clearHooks anymore.

You need a realtime listener to /managedObject/*

Again: our recommendation is to avoid it, but in case you need this you can use the RealtimeService or better ManagedObjectRealtimeService which already extends the RealtimeService.

You have doubts to deprecate and delete these methods in the future? Let me know and add a comment with your concerns.