November 2019
Beginner
804 pages
20h 1m
English
Now we know everything we need to serialize our media collections!
Go ahead and rewrite the saveMediaCollection method as follows:
saveMediaCollection(collection: Readonly<MediaCollection<T>>): Promise<void> { // 1
return new Promise<void>((resolve, reject) => { // 2
if (!collection) { // 3
reject(new Error("The list cannot be null or undefined!"));
}
console.log(`Saving media collection with the following name ${collection.name}`);
const serializedVersion = classToPlain(collection, { excludePrefixes: ["_"] }); // 4
console.log("Serialized version: ", serializedVersion);
this._store.setItem(collection.identifier, serializedVersion) // 5 .then(value => { // 6 console.log(`Saved the ${collection.name} ...Read now
Unlock full access