November 2019
Beginner
804 pages
20h 1m
English
Persisting data is nice but, of course, it's even nicer if it can be retrieved later.
Let's implement the load method as follows:
loadMediaCollection(identifier: string): Promise<MediaCollection<T>> {
console.log(`Trying to load media collection with the following identifier: ${identifier}`);
return new Promise<MediaCollection<T>>((resolve, reject) => {
this._store.getItem(identifier)
.then(value => {
console.log("Found the collection: ", value);
const retrievedCollection = plainToClassFromExist<MediaCollection<T>, any>(new MediaCollection<T>(this._type), value);
console.log("Retrieved collection: ", retrievedCollection); resolve(retrievedCollection); }) .catch(err => { reject(err); // let the ...Read now
Unlock full access