angular2-meteor
Advanced tools
Comparing version 0.6.3-beta.3 to 0.6.3-beta.4
export * from './observable-collection'; | ||
export * from './to-observable'; | ||
export * from './meteor-observable'; | ||
export * from './observable-cursor'; | ||
export * from './observable-subscription'; |
@@ -8,1 +8,3 @@ "use strict"; | ||
__export(require('./meteor-observable')); | ||
__export(require('./observable-cursor')); | ||
__export(require('./observable-subscription')); |
@@ -1,5 +0,6 @@ | ||
import { Observable } from 'rxjs/Rx'; | ||
import { Observable } from 'rxjs'; | ||
import { ObservableMeteorSubscription } from './observable-subscription'; | ||
export declare class MeteorObservable { | ||
static call<T>(name: string, ...args: any[]): Observable<T>; | ||
static subscribe<T>(name: string, ...args: any[]): Observable<T>; | ||
static subscribe<T>(name: string, ...args: any[]): ObservableMeteorSubscription<T>; | ||
} |
"use strict"; | ||
var Rx_1 = require('rxjs/Rx'); | ||
var rxjs_1 = require('rxjs'); | ||
var observable_subscription_1 = require('./observable-subscription'); | ||
var _ = require('lodash'); | ||
@@ -17,3 +18,3 @@ var MeteorObservable = (function () { | ||
} | ||
return Rx_1.Observable.create(function (observer) { | ||
return rxjs_1.Observable.create(function (observer) { | ||
Meteor.call.apply(Meteor, argumentsArray.concat([ | ||
@@ -43,3 +44,3 @@ function (error, result) { | ||
} | ||
return Rx_1.Observable.create(function (observer) { | ||
var observable = observable_subscription_1.ObservableMeteorSubscription.create(function (observer) { | ||
var handle = Meteor.subscribe.apply(Meteor, argumentsArray.concat([ | ||
@@ -56,2 +57,3 @@ { | ||
])); | ||
observable._meteorSubscriptionRef = handle; | ||
return function () { | ||
@@ -67,2 +69,3 @@ if (handle && handle.stop) { | ||
}); | ||
return observable; | ||
}; | ||
@@ -69,0 +72,0 @@ return MeteorObservable; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from 'rxjs/Rx'; | ||
import Selector = Mongo.Selector; | ||
@@ -7,2 +6,3 @@ import ObjectID = Mongo.ObjectID; | ||
import Modifier = Mongo.Modifier; | ||
import { ObservableCursor } from './observable-cursor'; | ||
export declare module MongoObservable { | ||
@@ -48,3 +48,3 @@ interface ConstructorOptions { | ||
transform?: Function; | ||
}): Observable<Array<T>>; | ||
}): ObservableCursor<Array<T>>; | ||
findOne(selector?: Selector | ObjectID | string, options?: { | ||
@@ -51,0 +51,0 @@ sort?: SortSpecifier; |
@@ -1,2 +0,2 @@ | ||
import { Observable } from 'rxjs/Rx'; | ||
export declare function toObservable<T>(cursor: Mongo.Cursor<T>): Observable<Array<T>>; | ||
import { ObservableCursor } from './observable-cursor'; | ||
export declare function toObservable<T>(cursor: Mongo.Cursor<T>): ObservableCursor<Array<T>>; |
"use strict"; | ||
var Rx_1 = require('rxjs/Rx'); | ||
var observable_cursor_1 = require('./observable-cursor'); | ||
function toObservable(cursor) { | ||
return Rx_1.Observable.create(function (observer) { | ||
var observable = observable_cursor_1.ObservableCursor.create(function (observer) { | ||
var handleChange = function () { | ||
observer.next(cursor.fetch()); | ||
}; | ||
var handler = cursor.observe({ | ||
added: handleChange, | ||
changed: handleChange, | ||
removed: handleChange | ||
}); | ||
var handler; | ||
var isReactive = observable.isReactive(); | ||
observable._cursorRef = cursor; | ||
observable._reloadRef = handleChange; | ||
if (isReactive) { | ||
handler = cursor.observe({ | ||
added: handleChange, | ||
changed: handleChange, | ||
removed: handleChange | ||
}); | ||
} | ||
else { | ||
handleChange(); | ||
} | ||
return function () { | ||
handler.stop(); | ||
if (isReactive && handler && handler.stop) { | ||
handler.stop(); | ||
} | ||
}; | ||
}); | ||
return observable; | ||
} | ||
exports.toObservable = toObservable; |
export * from './observable-collection'; | ||
export * from './to-observable'; | ||
export * from './meteor-observable'; | ||
export * from './observable-cursor'; | ||
export * from './observable-subscription'; |
@@ -1,2 +0,3 @@ | ||
import {Observable, Subscriber} from 'rxjs/Rx'; | ||
import {Observable, Subscriber} from 'rxjs'; | ||
import {ObservableMeteorSubscription} from './observable-subscription'; | ||
import * as _ from 'lodash'; | ||
@@ -31,3 +32,3 @@ | ||
public static subscribe<T>(name: string, ...args: any[]): Observable<T> { | ||
public static subscribe<T>(name: string, ...args: any[]): ObservableMeteorSubscription<T> { | ||
const argumentsArray: Array<any> = Array.prototype.slice.call(arguments); | ||
@@ -43,3 +44,4 @@ const lastParam = argumentsArray[argumentsArray.length - 1]; | ||
return Observable.create((observer: Subscriber<Meteor.Error | T>) => { | ||
const observable = | ||
ObservableMeteorSubscription.create((observer: Subscriber<Meteor.Error | T>) => { | ||
let handle = Meteor.subscribe.apply(Meteor, argumentsArray.concat([ | ||
@@ -57,2 +59,4 @@ { | ||
observable._meteorSubscriptionRef = handle; | ||
return () => { | ||
@@ -68,3 +72,5 @@ if (handle && handle.stop) { | ||
}); | ||
return <ObservableMeteorSubscription<T>>observable; | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
import {Observable} from 'rxjs/Rx'; | ||
import Selector = Mongo.Selector; | ||
@@ -8,2 +7,3 @@ import ObjectID = Mongo.ObjectID; | ||
import {toObservable} from './to-observable'; | ||
import {ObservableCursor} from './observable-cursor'; | ||
@@ -93,3 +93,3 @@ export module MongoObservable { | ||
transform ? : Function; | ||
}) : Observable<Array<T>> { | ||
}) : ObservableCursor<Array<T>> { | ||
const cursor = this.collection.find.apply(this.collection, arguments); | ||
@@ -96,0 +96,0 @@ |
@@ -1,5 +0,7 @@ | ||
import {Observable, Subscriber} from 'rxjs/Rx'; | ||
import {Subscriber} from 'rxjs/Rx'; | ||
import {ObservableCursor} from './observable-cursor'; | ||
export function toObservable<T>(cursor : Mongo.Cursor<T>) : Observable<Array<T>> { | ||
return Observable.create((observer : Subscriber<Array<T>>) => { | ||
export function toObservable<T>(cursor : Mongo.Cursor<T>) : ObservableCursor<Array<T>> { | ||
const observable = | ||
ObservableCursor.create((observer : Subscriber<Array<T>>) => { | ||
const handleChange = () => { | ||
@@ -9,12 +11,25 @@ observer.next(cursor.fetch()); | ||
let handler = cursor.observe({ | ||
added: handleChange, | ||
changed: handleChange, | ||
removed: handleChange | ||
}); | ||
let handler; | ||
let isReactive = observable.isReactive(); | ||
observable._cursorRef = cursor; | ||
observable._reloadRef = handleChange; | ||
if (isReactive) { | ||
handler = cursor.observe({ | ||
added: handleChange, | ||
changed: handleChange, | ||
removed: handleChange | ||
}); | ||
} else { | ||
handleChange(); | ||
} | ||
return () => { | ||
handler.stop(); | ||
if (isReactive && handler && handler.stop) { | ||
handler.stop(); | ||
} | ||
}; | ||
}); | ||
return <ObservableCursor<Array<T>>>observable; | ||
} |
{ | ||
"name": "angular2-meteor", | ||
"version": "0.6.3-beta.3", | ||
"version": "0.6.3-beta.4", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "angular", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
148459
90
2955