- added new subscribe() method to Parse.Query<T>.

- created test_query_subscribe() method to test new functionality.
This commit is contained in:
Wes Grimes
2018-02-07 20:11:45 -05:00
parent a03ea4fa1d
commit 422bdce576
2 changed files with 15 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
// David Poetzsch-Heffter <https://github.com/dpoetzsch>
// Cedric Kemp <https://github.com/jaeggerr>
// Flavio Negrão <https://github.com/flavionegrao>
// Wes Grimes <https://github.com/wesleygrimes>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -644,6 +645,7 @@ declare namespace Parse {
select(...keys: string[]): Query<T>;
skip(n: number): Query<T>;
startsWith(key: string, prefix: string): Query<T>;
subscribe(): Events;
withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): Query<T>;
withinKilometers(key: string, point: GeoPoint, maxDistance: number): Query<T>;
withinMiles(key: string, point: GeoPoint, maxDistance: number): Query<T>;

View File

@@ -491,3 +491,16 @@ function test_batch_operations() {
Parse.Object.fetchAllIfNeeded(games, { sessionToken: '' })
}
function test_query_subscribe() {
// create new query from Game object type
const query = new Parse.Query(Game);
// create subscription to Game object
const subscription = query.subscribe();
// listen for new Game objects created on Parse server
subscription.on('create', (game: any) => {
console.log(game);
});
}