-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
Description
Querying a PersistentList made of EmbeddedPersistentObject always yields a new instance. This is confusing. Is this wanted ?
How can I get around this ? Should I wrap the players getter with memoization/caching logic ? Shouldn't Objectory take care of this ?
Here's a stripped-down test case :
/// A player is per-game, unlike the user, so I embed it.
class Player extends EmbeddedPersistentObject {
Player ();
}
class Game extends PersistentObject {
// There may be more than two players
List<Player> get players => getPersistentList(Player, 'players');
// ... but the first two are black and white.
Player get black => players[0];
Player get white => players[1];
Game(){
players.add(new Player());
players.add(new Player());
}
}
g = new Game();
expect(g.black, same(g.black)); // <-- FAILS
I'm probably missing something here (I'm very much new to Objectory).