Skip to content

Commit

Permalink
Update type definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
omegascorp committed Sep 14, 2017
1 parent 2774be7 commit 29a41a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "owljs",
"version": "0.8.26",
"version": "0.8.27",
"description": "Backbone-like frontend library",
"main": "index.js",
"typings": "typescript/owl.d.ts",
Expand Down
18 changes: 9 additions & 9 deletions typescript/owl.Collection.d.ts
Expand Up @@ -4,22 +4,22 @@ import {EventEmitter} from './owl.EventEmitter';
/**
* Collection options
*/
export interface ICollectionOptions {
export interface ICollectionOptions<M> {
url: string;
model: typeof Model;
model: M;
}

/**
* owl.Collection
*/
export class Collection<T> extends EventEmitter {
export class Collection<I, M> extends EventEmitter {
protected url: string;

constructor(data: T[], options: ICollectionOptions);
constructor(data: I[], options: ICollectionOptions<M>);
/**
* Gets data from the server
*/
fetch(query?: Object): Promise<T[]>;
fetch(query?: Object): Promise<I[]>;

/**
* Removes models from collection
Expand All @@ -29,17 +29,17 @@ export class Collection<T> extends EventEmitter {
/**
* Sets collection data
*/
setData(data?: T[]): void;
setData(data?: I[]): void;

/**
* Gets collection data
*/
getData(): T[];
getData(): I[];

/**
* Gets collection models
*/
getModels(): Model[];
getModels(): M[];

/**
* Gets collection length
Expand All @@ -49,7 +49,7 @@ export class Collection<T> extends EventEmitter {
/**
* Gets model by index
*/
get(index: number): Model;
get(index: number): M;

/**
* Updates collection internal data value based on index
Expand Down
14 changes: 7 additions & 7 deletions typescript/owl.Model.d.ts
Expand Up @@ -13,11 +13,11 @@ export interface IModelOptions {
/**
* owl.Model
*/
export class Model<T> extends EventEmitter {
export class Model<I> extends EventEmitter {
protected url: string;
protected idAttribute: string;

constructor(data: T, options: IModelOptions);
constructor(data: I, options: IModelOptions);
/**
* Gets attribute by name
*/
Expand All @@ -31,7 +31,7 @@ export class Model<T> extends EventEmitter {
/**
* Gets data from the server
*/
fetch(query?: Object): Promise<T>;
fetch(query?: Object): Promise<I>;

/**
* Removes all attributes from the model
Expand All @@ -46,12 +46,12 @@ export class Model<T> extends EventEmitter {
/**
* Updates local data and saves model
*/
update(data: T, query?: Object): Promise<Object>;
update(data: I, query?: Object): Promise<Object>;

/**
* Partially updates model
*/
patch(data: T, query?: Object, path?: String): Promise<Object>;
patch(data: I, query?: Object, path?: String): Promise<Object>;

/**
* Removes a model
Expand All @@ -61,12 +61,12 @@ export class Model<T> extends EventEmitter {
/**
* Gets model data
*/
getData(): T;
getData(): I;

/**
* Sets model data
*/
setData(T): void;
setData(data: I): void;

/**
* Gets model collection
Expand Down

0 comments on commit 29a41a1

Please sign in to comment.