2014-09-26 11:20:08 -07:00
|
|
|
import {ProtoRecord, Record} from './record';
|
2014-09-28 13:55:01 -07:00
|
|
|
import {FIELD} from 'facade/lang';
|
2014-09-26 11:20:08 -07:00
|
|
|
|
|
|
|
export class ProtoWatchGroup {
|
|
|
|
@FIELD('final _headRecord:ProtoRecord')
|
|
|
|
@FIELD('final _tailRecord:ProtoRecord')
|
|
|
|
constructor() {
|
|
|
|
this._headRecord = null;
|
|
|
|
this._tailRecord = null;
|
|
|
|
}
|
|
|
|
|
2014-09-30 15:50:20 -07:00
|
|
|
/**
|
|
|
|
* Parses [expression] into [ProtoRecord]s and adds them to [ProtoWatchGroup].
|
|
|
|
*
|
|
|
|
* @param expression The expression to watch
|
|
|
|
* @param memento an opeque object which will be bassed to WatchGroupDispatcher on
|
|
|
|
* detecting a change.
|
|
|
|
* @param shallow Should collections be shallow watched
|
|
|
|
*/
|
2014-09-26 11:20:08 -07:00
|
|
|
watch(
|
|
|
|
expression:String,
|
2014-09-30 15:50:20 -07:00
|
|
|
memento,
|
|
|
|
{shallow/*=false*/}:{shallow:bool})
|
2014-09-26 11:20:08 -07:00
|
|
|
{
|
2014-09-30 15:50:20 -07:00
|
|
|
/// IMPLEMENT
|
2014-09-26 11:20:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
instantiate(dispatcher:WatchGroupDispatcher):WatchGroup {
|
|
|
|
var watchGroup:WatchGroup = new WatchGroup(this, dispatcher);
|
|
|
|
var head:Record = null;
|
|
|
|
var tail:Record = null;
|
|
|
|
var proto:ProtoRecord = this._headRecord;
|
|
|
|
|
|
|
|
while(proto != null) {
|
|
|
|
tail = proto.instantiate(watchGroup);
|
|
|
|
if (head == null) head = tail;
|
|
|
|
proto = proto.next;
|
|
|
|
}
|
|
|
|
|
|
|
|
proto = this._headRecord;
|
|
|
|
while(proto != null) {
|
2014-09-28 16:29:11 -07:00
|
|
|
proto.instantiateComplete();
|
|
|
|
proto = proto.next;
|
2014-09-26 11:20:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
watchGroup._headRecord = head;
|
|
|
|
watchGroup._tailRecord = tail;
|
|
|
|
return watchGroup;
|
|
|
|
}
|
2014-09-30 15:50:20 -07:00
|
|
|
|
2014-09-26 11:20:08 -07:00
|
|
|
}
|
|
|
|
|
2014-09-19 16:38:37 -07:00
|
|
|
export class WatchGroup {
|
2014-09-26 11:20:08 -07:00
|
|
|
@FIELD('final protoWatchGroup:ProtoWatchGroup')
|
2014-09-19 16:38:37 -07:00
|
|
|
@FIELD('final dispatcher:WatchGroupDispatcher')
|
2014-09-26 11:20:08 -07:00
|
|
|
@FIELD('final _headRecord:Record')
|
|
|
|
@FIELD('final _tailRecord:Record')
|
|
|
|
constructor(protoWatchGroup:ProtoWatchGroup, dispatcher:WatchGroupDispatcher) {
|
|
|
|
this.protoWatchGroup = protoWatchGroup;
|
|
|
|
this.dispatcher = dispatcher;
|
|
|
|
this._headRecord = null;
|
|
|
|
this._tailRecord = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
insertChildGroup(newChild:WatchGroup, insertAfter:WatchGroup) {
|
|
|
|
/// IMPLEMENT
|
|
|
|
}
|
|
|
|
|
|
|
|
remove() {
|
|
|
|
/// IMPLEMENT
|
|
|
|
}
|
|
|
|
|
2014-09-30 16:39:37 -07:00
|
|
|
/**
|
|
|
|
* Sets the context (the object) on which the change detection expressions will
|
|
|
|
* dereference themselves on. Since the WatchGroup can be reused the context
|
|
|
|
* can be re-set many times during the lifetime of the WatchGroup.
|
|
|
|
*
|
|
|
|
* @param context the new context for change dection for the curren WatchGroup
|
|
|
|
*/
|
|
|
|
setContext(context) {
|
|
|
|
}
|
2014-09-26 11:20:08 -07:00
|
|
|
}
|
2014-09-28 16:29:11 -07:00
|
|
|
|
|
|
|
export class WatchGroupDispatcher {
|
|
|
|
onRecordChange(record:Record, context) {}
|
|
|
|
}
|