Skip to content

Commit

Permalink
Merge branch 'observable' into new-rms-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Jul 21, 2023
2 parents 678bd25 + 20069c6 commit 4e5c97b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
7 changes: 7 additions & 0 deletions libs/ObservablePromise.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare class ObservablePromise<T> {
private _status;
private _promise;
constructor(promise: Promise<T>);
get promise(): Promise<T>;
get status(): 'pending' | 'fulfilled' | 'rejected';
}
19 changes: 19 additions & 0 deletions libs/ObservablePromise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class ObservablePromise {
constructor(promise) {
this._status = 'pending';
this._promise = promise
.then((value) => {
this._status = 'fulfilled';
return value;
}, (error) => {
this._status = 'rejected';
throw error;
});
}
get promise() {
return this._promise;
}
get status() {
return this._status;
}
}
26 changes: 26 additions & 0 deletions libs/ObservablePromise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export class ObservablePromise<T> {
private _status: 'pending' | 'fulfilled' | 'rejected' = 'pending';
private _promise: Promise<T>;

constructor(promise: Promise<T>) {
this._promise = promise
.then(
(value: T) => {
this._status = 'fulfilled';
return value;
},
(error) => {
this._status = 'rejected';
throw error;
}
);
}

get promise(): Promise<T> {
return this._promise;
}

get status(): 'pending' | 'fulfilled' | 'rejected' {
return this._status;
}
}
2 changes: 1 addition & 1 deletion models/Group.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare let attributes: {
allowNull: boolean;
};
/** Images */
images: MediaFile[];
images: string[] | MediaFile[];
/** PlaySholder for group dishes */
dishesPlaceholder: MediaFile[];
/** The person readable isii*/
Expand Down
2 changes: 1 addition & 1 deletion models/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let attributes = {
images: {
collection: "mediafile",
via: "group",
} as unknown as MediaFile[],
} as unknown as MediaFile[] | string[],

/** PlaySholder for group dishes */
dishesPlaceholder: {
Expand Down

0 comments on commit 4e5c97b

Please sign in to comment.