Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use getRaw and setRaw in PilesPersister so that rehydrate and dehydra…
…te don't kick in. This helps avoid situations in which things that are already dehydrated get dehydrated into nulls.
- Loading branch information
Showing
5 changed files
with
59 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Constructing decks: | ||
https://mscgen.js.org/?lang=msgenny&mirrorentities=true&style=classic&msc=width%3D%221200%22%2C%20watermark%3D%22App%20initialization%22%3B%0A%0AassembleMainMachine%20%3D%3E%20CollectionStore%3A%20(for%20deckCollectionStore)%3B%0ACollectionStore%20%3D%3E%20%22loadThings%22%3B%0AloadThings%20%3E%3E%20CollectionStore%3A%20deck%20objects%3B%0ACollectionStore%20%3E%3E%20assembleMainMachine%3A%20collectionStore%3B%0A%23assembleMainMachine%20note%20assembleMainMachine%3A%20After%20an%20indeterminate%20amount%20of%20time%E2%80%A6%3B%0A%0AassembleMainMachine%20%3D%3E%20collectionStore.get%3B%0AcollectionStore.get%20%3D%3E%20collectionStore.rehydrate%3B%0AcollectionStore.rehydrate%20%3D%3E%20idsPersister.get%3B%0A%0AidsPersister.get%20%3E%3E%20collectionStore.rehydrate%3A%20ids%3B%0AcollectionStore.rehydrate%20%3D%3E%20thingPersister.get%3A%20ids%3B%0AthingPersister.get%20%3E%3E%20collectionStore.rehydrate%3A%20Decks%3B%0AcollectionStore.rehydrate%20%3E%3E%20collectionStore.get%3A%20Decks%3B%0AcollectionStore.get%20%3E%3E%20assembleMainMachine%3A%20Decks%3B%0A%0AassembleMainMachine%20%3D%3E%20ThingStore%3A%20Deck%3B%0AThingStore%20%3E%3E%20assembleMainMachine%3A%20deckStore%3B%0A%0AassembleMainMachine%20%3D%3E%20deckResponderMapper%3A%20%22collectionStore%2C%20deckStore%22%3B%0AdeckResponderMapper%20%3D%3E%20deckStore.get%3B%0AdeckStore.get%20%3D%3E%20rehydrateDeck%3B%0ArehydrateDeck%20%3D%3E%20thingPersister.get%3A%20(pile%20id)%3B%0AthingPersister.get%20%3E%3E%20rehydrateDeck%3A%20Pile%3B%0ArehydrateDeck%20%3E%3E%20deckStore.get%20%3A%20Pile%3B%0AdeckStore.get%20%3E%3E%20deckResponderMapper%20%3A%20Deck%3B | ||
https://mscgen.js.org/?lang=msgenny&mirrorentities=true&style=classic&msc=width%3D%221200%22%2C%20watermark%3D%22App%20initialization%22%3B%0A%0AassembleMainMachine%20%3D%3E%20CollectionStore%3A%20(for%20deckCollectionStore)%3B%0ACollectionStore%20%3D%3E%20%22loadThings%22%3B%0AloadThings%20%3E%3E%20CollectionStore%3A%20deck%20objects%3B%0ACollectionStore%20%3E%3E%20assembleMainMachine%3A%20collectionStore%3B%0A%23assembleMainMachine%20note%20assembleMainMachine%3A%20After%20an%20indeterminate%20amount%20of%20time%E2%80%A6%3B%0A%0AassembleMainMachine%20%3D%3E%20collectionStore.get%3B%0AcollectionStore.get%20%3D%3E%20collectionStore.rehydrate%3B%0AcollectionStore.rehydrate%20%3D%3E%20idsPersister.get%3B%0A%0AidsPersister.get%20%3E%3E%20collectionStore.rehydrate%3A%20ids%3B%0AcollectionStore.rehydrate%20%3D%3E%20thingPersister.get%3A%20ids%3B%0AthingPersister.get%20%3E%3E%20collectionStore.rehydrate%3A%20Decks%3B%0AcollectionStore.rehydrate%20%3E%3E%20collectionStore.get%3A%20Decks%3B%0AcollectionStore.get%20%3E%3E%20assembleMainMachine%3A%20Decks%3B%0A%0AassembleMainMachine%20%3D%3E%20ThingStore%3A%20Deck%3B%0AThingStore%20%3E%3E%20assembleMainMachine%3A%20deckStore%3B%0A%0AassembleMainMachine%20%3D%3E%20deckResponderMapper%3A%20%22collectionStore%2C%20deckStore%22%3B%0AdeckResponderMapper%20%3D%3E%20deckStore.get%3B%0AdeckStore.get%20%3D%3E%20rehydrateDeck%3B%0ArehydrateDeck%20%3D%3E%20thingPersister.get%3A%20(pile%20id)%3B%0AthingPersister.get%20%3E%3E%20rehydrateDeck%3A%20Pile%3B%0ArehydrateDeck%20%3E%3E%20deckStore.get%20%3A%20Deck%20(with%20Pile%20objects%20in%20piles)%3B%0AdeckStore.get%20%3E%3E%20deckResponderMapper%20%3A%20Deck%3B | ||
|
||
Add pile: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Deck, Persister } from "../types"; | ||
|
||
export function RehydrateDeck(thingPersister: Persister) { | ||
return rehydrateDeck; | ||
|
||
// These functions should not mess with val. | ||
function rehydrateDeck(val): Deck { | ||
if (!val.piles) { | ||
return; | ||
} | ||
var rehydrated = Object.assign({}, val, { piles: val.piles.map(getPileForId) }); | ||
// What about rehydrating the properties of each pile? | ||
return rehydrated; | ||
} | ||
|
||
function getPileForId(id: string) { | ||
return thingPersister.get(id); | ||
} | ||
} | ||
|
||
export function DehydrateDeck(thingPersister: Persister) { | ||
return dehydrateDeck; | ||
|
||
function dehydrateDeck(val): Deck { | ||
if (!val.piles) { | ||
return val; | ||
} | ||
// TODO: Maybe deep copy? | ||
var dehydrated = Object.assign({}, val, { piles: val.piles.map(pile => pile.id) }); | ||
return dehydrated; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters