mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
- added new subscribe() method to Parse.Query<T>.
- created test_query_subscribe() method to test new functionality.
This commit is contained in:
2
types/parse/index.d.ts
vendored
2
types/parse/index.d.ts
vendored
@@ -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>;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user