fix(types): parametrize QueryList.
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
library angular2.src.core.compiler.base_query_list;
|
library angular2.src.core.compiler.base_query_list;
|
||||||
|
|
||||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,8 +9,8 @@ import 'dart:collection';
|
|||||||
* In the future this class will implement an Observable interface.
|
* In the future this class will implement an Observable interface.
|
||||||
* For now it uses a plain list of observable callbacks.
|
* For now it uses a plain list of observable callbacks.
|
||||||
*/
|
*/
|
||||||
class BaseQueryList extends Object with IterableMixin<Directive> {
|
class BaseQueryList<T> extends Object with IterableMixin<T> {
|
||||||
List<Directive> _results;
|
List<T> _results;
|
||||||
List _callbacks;
|
List _callbacks;
|
||||||
bool _dirty;
|
bool _dirty;
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ class BaseQueryList extends Object with IterableMixin<Directive> {
|
|||||||
_callbacks = [],
|
_callbacks = [],
|
||||||
_dirty = false;
|
_dirty = false;
|
||||||
|
|
||||||
Iterator<Directive> get iterator => _results.iterator;
|
Iterator<T> get iterator => _results.iterator;
|
||||||
|
|
||||||
reset(newList) {
|
reset(newList) {
|
||||||
_results = newList;
|
_results = newList;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injectable Objects that contains a live list of child directives in the light Dom of a directive.
|
* Injectable Objects that contains a live list of child directives in the light Dom of a directive.
|
||||||
@ -10,8 +9,8 @@ import {Directive} from 'angular2/src/core/annotations_impl/annotations';
|
|||||||
*
|
*
|
||||||
* @exportedAs angular2/view
|
* @exportedAs angular2/view
|
||||||
*/
|
*/
|
||||||
export class BaseQueryList {
|
export class BaseQueryList<T> {
|
||||||
_results: List<Directive>;
|
_results: List<T>;
|
||||||
_callbacks;
|
_callbacks;
|
||||||
_dirty;
|
_dirty;
|
||||||
|
|
||||||
|
@ -947,7 +947,7 @@ export class ElementInjector extends TreeNode<ElementInjector> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createQueryRef(directive): void {
|
private _createQueryRef(directive): void {
|
||||||
var queryList = new QueryList();
|
var queryList = new QueryList<any>();
|
||||||
if (isBlank(this._query0)) {
|
if (isBlank(this._query0)) {
|
||||||
this._query0 = new QueryRef(directive, queryList, this);
|
this._query0 = new QueryRef(directive, queryList, this);
|
||||||
} else if (isBlank(this._query1)) {
|
} else if (isBlank(this._query1)) {
|
||||||
@ -1515,10 +1515,10 @@ class QueryError extends BaseException {
|
|||||||
|
|
||||||
class QueryRef {
|
class QueryRef {
|
||||||
directive;
|
directive;
|
||||||
list: QueryList;
|
list: QueryList<any>;
|
||||||
originator: ElementInjector;
|
originator: ElementInjector;
|
||||||
|
|
||||||
constructor(directive, list: QueryList, originator: ElementInjector) {
|
constructor(directive, list: QueryList<any>, originator: ElementInjector) {
|
||||||
this.directive = directive;
|
this.directive = directive;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.originator = originator;
|
this.originator = originator;
|
||||||
|
@ -75,7 +75,7 @@ import {BaseQueryList} from './base_query_list';
|
|||||||
*
|
*
|
||||||
* @exportedAs angular2/view
|
* @exportedAs angular2/view
|
||||||
*/
|
*/
|
||||||
export class QueryList extends BaseQueryList {
|
export class QueryList<T> extends BaseQueryList<T> {
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
onChange(callback) { return super.onChange(callback); }
|
onChange(callback) { return super.onChange(callback); }
|
||||||
|
@ -157,8 +157,8 @@ class NeedsAttributeNoType {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class NeedsQuery {
|
class NeedsQuery {
|
||||||
query: QueryList;
|
query: QueryList<CountingDirective>;
|
||||||
constructor(@Query(CountingDirective) query: QueryList) { this.query = query; }
|
constructor(@Query(CountingDirective) query: QueryList<CountingDirective>) { this.query = query; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -1540,10 +1540,10 @@ class ToolbarViewContainer {
|
|||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class ToolbarComponent {
|
class ToolbarComponent {
|
||||||
query: QueryList;
|
query: QueryList<ToolbarPart>;
|
||||||
ctxProp: string;
|
ctxProp: string;
|
||||||
|
|
||||||
constructor(@Query(ToolbarPart) query: QueryList) {
|
constructor(@Query(ToolbarPart) query: QueryList<ToolbarPart>) {
|
||||||
this.ctxProp = 'hello world';
|
this.ctxProp = 'hello world';
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,8 @@ class TextDirective {
|
|||||||
@View({directives: [NgFor], template: '<div *ng-for="var dir of query">{{dir.text}}|</div>'})
|
@View({directives: [NgFor], template: '<div *ng-for="var dir of query">{{dir.text}}|</div>'})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class NeedsQuery {
|
class NeedsQuery {
|
||||||
query: QueryList;
|
query: QueryList<TextDirective>;
|
||||||
constructor(@Query(TextDirective) query: QueryList) { this.query = query; }
|
constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
|
||||||
}
|
}
|
||||||
|
|
||||||
var _constructiontext = 0;
|
var _constructiontext = 0;
|
||||||
|
@ -46,10 +46,10 @@ class App {
|
|||||||
template: `{{frame.name}}(<span *ng-for="var lock of locks">{{lock.name}}</span>)`
|
template: `{{frame.name}}(<span *ng-for="var lock of locks">{{lock.name}}</span>)`
|
||||||
})
|
})
|
||||||
class Door {
|
class Door {
|
||||||
locks: QueryList;
|
locks: QueryList<Lock>;
|
||||||
frame: Frame;
|
frame: Frame;
|
||||||
|
|
||||||
constructor(@Query(forwardRef(() => Lock)) locks: QueryList,
|
constructor(@Query(forwardRef(() => Lock)) locks: QueryList<Lock>,
|
||||||
@Inject(forwardRef(() => Frame)) frame: Frame) {
|
@Inject(forwardRef(() => Frame)) frame: Frame) {
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.locks = locks;
|
this.locks = locks;
|
||||||
|
Reference in New Issue
Block a user