Closed kaisellgren closed 11 years ago
I believe you may solve this problem slightly changing your model to somewhat like:
final PersistentList<User> _managers => new PersistentList<User>(this, 'User', 'managers');
PersistentList<User> get managers => _managers;
You are right, I can take a different approach. However, I had to do something slightly different what you proposed, here's what works:
class Community extends BaseModel {
Community() {
_managers = new PersistentList<User>(this, 'User', 'managers');
}
PersistentList<User> _managers;
PersistentList<User> get managers => _managers;
}
The one you mentioned, used arrow in assignment which does not work... either you specify a method (arrow), or you assign (=
without arrow). And assignment doesn't work with this
.
I'm wondering... since Web UI is a popular thing in the Dart world, should we mention something in the docs or maybe even suggest a different way to write this in the Objectory docs?
Silly mistake, i wrote code just here. Obviously I meant
final PersistentList<User> _managers = new PersistentList<User>(this, 'User', 'managers');
PersistentList<User> get managers => _managers;
I believe there is better way to define List properties in model: I've just added getPersistentList method to PersistentObject (used similar to getEmbeddedObject) So class Person from test model now looks like:
class Person extends PersistentObject {
String get firstName => getProperty('firstName');
set firstName(String value) => setProperty('firstName',value);
....
....
Address get address => getEmbeddedObject('Address', 'address');
Person get father => getLinkedObject('father');
set father (PersistentObject value) => setLinkedObject('father',value);
List<Person> get children => getPersistentList('Person','children');
}
property children constantly return same object.
All this in last version on pub.dartlang.org
Good to know -- is this updated to all docs? Please do so if not :)
All docs are very old. Do you wish to help?
I guess I could at the weekend. I'll bookmark this page as a reminder to myself. Can you add me as a collaborator to this repository? I won't push any radical code changes, if I ever do it's a separate branch.
Fork the repository and make a pull request whith your changes. I believe that's usual way to contribute on github
The way we use PersistentList:
i.e. returning a new persistent list, causes:
Because I believe the list "changes" all the time when Web UI is trying to compare if it has changed:
Could we do something about this? Maybe implement
==
andhashCode
?