Merge pull request #23493 from wesleygrimes/add-subscribe-to-query

Adding subscribe() method to Parse.Query<T>
This commit is contained in:
Daniel Rosenwasser
2018-02-13 11:01:49 -08:00
committed by GitHub
2 changed files with 15 additions and 0 deletions
+2
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>;
+13
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);
});
}