Release Notes / Version 11.2210
Table Of Contents
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:
There are a few callback-based methods whose
callback
parameter has been optional before. When used withoutcallback
, they used to returnvoid
, but now return aPromise
. If code "hands through" thevoid
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 areRemoteBean#load()
,invalidate()
andflush()
.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, sinceRemoteBeanImpl
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 tosuper
, returning thesuper
call's optional result, the Promise.
(CMS-21750)