close

Filter

loading table of contents...

Release Notes / Version 11.2207

Table Of Contents

Added Promises-based Alternatives for Callback-based Studio Client API

In Studio Client's remote API, all callback-based API methods now support an alternative signature: When called without the callback argument, they return a Promise instead of void . For example, Content#rename() now has the following overloaded signatures:

rename(newName: string, callback: () => void): void;
rename(newName: string): Promise<void>;

You can still use the API with a callback, but also without, and then use the returned Promise to react on the result.

This means this change is backwards-compatible, save in two special cases:

  1. There are a few callback-based methods whose callback parameter has been optional before. When used without callback , they used to return void , but now return a Promise . If code "hands through" the void result (bad practice!), this now results in a TypeScript type error during build. The typical usage where this error occurs is when calling the changed method from an arrow function in short-hand form. To fix the error, simply add curly braces to the function body. The most prominent methods of this kind are RemoteBean#load() , invalidate() and flush() .

  2. When your code does not only use the API, but actually extends Studio Client API (typically a custom RemoteBean ) and implements/overrides any of the complemented methods (usually not necessary, since RemoteBeanImpl does that for you), your implementing method must also be complemented by the new overloaded method signature (TypeScript will tell you so). For the Promise-based version to work, your implementation must also regard the new case, usually by delegating to super , returning the super call's optional result, the Promise.

(CMS-21750)

Search Results

Table Of Contents