forked from mystiq/hydrogen-web
Convert RetainedValue.js to ts
This commit is contained in:
parent
88ec1b575d
commit
ea0adb4407
2 changed files with 7 additions and 5 deletions
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import {ObservableMap} from "../../../observable/map/ObservableMap.js";
|
||||
import {RetainedValue} from "../../../utils/RetainedValue.js";
|
||||
import {RetainedValue} from "../../../utils/RetainedValue";
|
||||
|
||||
export class MemberList extends RetainedValue {
|
||||
constructor({members, closeCallback}) {
|
||||
|
|
|
@ -15,16 +15,18 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
export class RetainedValue {
|
||||
constructor(freeCallback) {
|
||||
private readonly _freeCallback: () => void;
|
||||
private _retentionCount: number = 1;
|
||||
|
||||
constructor(freeCallback: () => void) {
|
||||
this._freeCallback = freeCallback;
|
||||
this._retentionCount = 1;
|
||||
}
|
||||
|
||||
retain() {
|
||||
retain(): void {
|
||||
this._retentionCount += 1;
|
||||
}
|
||||
|
||||
release() {
|
||||
release(): void {
|
||||
this._retentionCount -= 1;
|
||||
if (this._retentionCount === 0) {
|
||||
this._freeCallback();
|
Loading…
Reference in a new issue