Skip to content

PersistentList[] of EmbeddedPersistentObject yields a new instance #65

@Goutte

Description

@Goutte

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).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions