potion-client
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -87,2 +87,4 @@ export declare function readonly(target: any, property: any): void; | ||
private _uri; | ||
private _options; | ||
private _subscribers; | ||
private _items; | ||
@@ -95,5 +97,7 @@ private _page; | ||
uri: any; | ||
}, items: any, count: any, options: PaginationOptions); | ||
[Symbol.iterator](): IterableIterator<Item>; | ||
}, items: any, count: any, options: PotionRequestOptions); | ||
[Symbol.iterator](): IterableIterator<T>; | ||
update(items: any, count: any): void; | ||
subscribe(cb: (pagination: Pagination<T>) => void): void; | ||
toArray(): T[]; | ||
} |
25
base.js
@@ -203,3 +203,3 @@ "use strict"; | ||
else { | ||
return new Pagination({ uri: uri, potion: _this }, data, count, { page: page, perPage: perPage }); | ||
return new Pagination({ uri: uri, potion: _this }, data, count, options); | ||
} | ||
@@ -306,8 +306,11 @@ } | ||
var potion = _a.potion, uri = _a.uri; | ||
this._subscribers = []; | ||
this._items = []; | ||
this._potion = potion; | ||
this._uri = uri; | ||
this._options = options; | ||
(_b = this._items).push.apply(_b, items); | ||
this._page = options.page; | ||
this._perPage = options.perPage; | ||
var _c = options.data, page = _c.page, perPage = _c.perPage; | ||
this._page = page; | ||
this._perPage = perPage; | ||
this._total = count; | ||
@@ -321,4 +324,12 @@ var _b; | ||
set: function (page) { | ||
this._potion.fetch({ page: page, perPage: this.perPage }, this); | ||
var _this = this; | ||
this._page = page; | ||
Object.assign(this._options, { | ||
data: Object.assign(this._options.data, { page: page }) | ||
}); | ||
this._potion.fetch(this._uri, this._options, this).then(function () { | ||
_this._subscribers.forEach(function (subscriber) { | ||
subscriber(_this); | ||
}); | ||
}); | ||
}, | ||
@@ -357,2 +368,8 @@ enumerable: true, | ||
}; | ||
Pagination.prototype.subscribe = function (cb) { | ||
this._subscribers.push(cb); | ||
}; | ||
Pagination.prototype.toArray = function () { | ||
return this._items; | ||
}; | ||
return Pagination; | ||
@@ -359,0 +376,0 @@ }()); |
{ | ||
"name": "potion-client", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A ES6 client for APIs written in Flask-Potion", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
50626
636