angular2-meteor
Advanced tools
Comparing version 0.7.0-beta.1 to 0.7.0-beta.2
@@ -0,1 +1,13 @@ | ||
<a name="0.7.0-beta.1"></a> | ||
# [0.7.0-beta.1](https://github.com/Urigo/angular2-meteor/compare/0.6.0...v0.7.0-beta.1) (2016-08-21) | ||
### Bug Fixes | ||
* **MeteorComponent:** fix #337 ([63f95b6](https://github.com/Urigo/angular2-meteor/commit/63f95b6)), closes [#337](https://github.com/Urigo/angular2-meteor/issues/337) [#323](https://github.com/Urigo/angular2-meteor/issues/323) | ||
* #331 ([6fe0d45](https://github.com/Urigo/angular2-meteor/commit/6fe0d45)) | ||
* fix #331 ([5a976ac](https://github.com/Urigo/angular2-meteor/commit/5a976ac)), closes [#331](https://github.com/Urigo/angular2-meteor/issues/331) | ||
<a name="0.6.2"></a> | ||
@@ -2,0 +14,0 @@ ## [0.6.2](https://github.com/Urigo/angular2-meteor/compare/0.6.0...v0.6.2) (2016-07-20) |
'use strict'; | ||
var utils_1 = require('./utils'); | ||
var CursorHandle = (function () { | ||
import { check } from './utils'; | ||
export var CursorHandle = (function () { | ||
function CursorHandle(hCurObserver, hAutoNotify) { | ||
utils_1.check(hAutoNotify, Match.Optional(Tracker.Computation)); | ||
utils_1.check(hCurObserver, Match.Where(function (observer) { | ||
check(hAutoNotify, Match.Optional(Tracker.Computation)); | ||
check(hCurObserver, Match.Where(function (observer) { | ||
return !!observer.stop; | ||
@@ -20,2 +20,1 @@ })); | ||
}()); | ||
exports.CursorHandle = CursorHandle; |
@@ -1,8 +0,6 @@ | ||
export * from './patch'; | ||
/// <reference path="../typings/index.d.ts" /> | ||
export * from './zone_utils'; | ||
export * from './mongo_cursor_observer'; | ||
export * from './mongo_cursor_differ'; | ||
export * from './meteor_component'; | ||
export * from './meteor_reactive'; | ||
export * from './providers'; | ||
export * from './data_observer'; | ||
export * from './meteor_module'; | ||
export * from './minimongo-observable/index'; |
@@ -1,12 +0,6 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
__export(require('./patch')); | ||
__export(require('./mongo_cursor_observer')); | ||
__export(require('./mongo_cursor_differ')); | ||
__export(require('./meteor_component')); | ||
__export(require('./providers')); | ||
__export(require('./data_observer')); | ||
__export(require('./meteor_module')); | ||
__export(require('./minimongo-observable/index')); | ||
/// <reference path="../typings/index.d.ts" /> | ||
export * from './zone_utils'; | ||
export * from './mongo_cursor_observer'; | ||
export * from './mongo_cursor_differ'; | ||
export * from './meteor_reactive'; | ||
export * from './providers'; |
@@ -1,6 +0,2 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
require('angular2-meteor-polyfills'); | ||
__export(require('./index')); | ||
import 'angular2-meteor-polyfills'; | ||
export * from './index'; |
@@ -1,3 +0,2 @@ | ||
import { ChangeDetectorRef } from '@angular/core'; | ||
import { DefaultIterableDifferFactory, CollectionChangeRecord, DefaultIterableDiffer } from '@angular/core/src/change_detection/differs/default_iterable_differ'; | ||
import { CollectionChangeRecord, IterableDifferFactory, DefaultIterableDiffer, ChangeDetectorRef } from '@angular/core'; | ||
import { MongoCursorObserver } from './mongo_cursor_observer'; | ||
@@ -7,3 +6,3 @@ export interface ObserverFactory { | ||
} | ||
export declare class MongoCursorDifferFactory extends DefaultIterableDifferFactory { | ||
export declare class MongoCursorDifferFactory implements IterableDifferFactory { | ||
supports(obj: Object): boolean; | ||
@@ -29,3 +28,2 @@ create(cdRef: ChangeDetectorRef): MongoCursorDiffer; | ||
private _sub; | ||
private _zone; | ||
constructor(cdRef: ChangeDetectorRef, obsFactory: ObserverFactory); | ||
@@ -39,3 +37,3 @@ forEachAddedItem(fn: Function): void; | ||
onDestroy(): void; | ||
observer: MongoCursorObserver; | ||
readonly observer: MongoCursorObserver; | ||
_destroyObserver(): void; | ||
@@ -42,0 +40,0 @@ _updateLatestValue(changes: any): void; |
'use strict'; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var default_iterable_differ_1 = require('@angular/core/src/change_detection/differs/default_iterable_differ'); | ||
var mongo_cursor_observer_1 = require('./mongo_cursor_observer'); | ||
import { CollectionChangeRecord, DefaultIterableDiffer } from '@angular/core'; | ||
import { MongoCursorObserver, AddChange, MoveChange, RemoveChange, UpdateChange } from './mongo_cursor_observer'; | ||
function checkIfMongoCursor(cursor) { | ||
return mongo_cursor_observer_1.MongoCursorObserver.isCursor(cursor); | ||
return MongoCursorObserver.isCursor(cursor); | ||
} | ||
@@ -19,3 +14,3 @@ // Creates an MongoCursorObserver instance for a Mongo.Cursor instance. | ||
if (checkIfMongoCursor(cursor)) { | ||
return new mongo_cursor_observer_1.MongoCursorObserver(cursor); | ||
return new MongoCursorObserver(cursor); | ||
} | ||
@@ -30,6 +25,4 @@ return null; | ||
// differ it needs to create and use for the current collection. | ||
var MongoCursorDifferFactory = (function (_super) { | ||
__extends(MongoCursorDifferFactory, _super); | ||
export var MongoCursorDifferFactory = (function () { | ||
function MongoCursorDifferFactory() { | ||
_super.apply(this, arguments); | ||
} | ||
@@ -41,4 +34,3 @@ MongoCursorDifferFactory.prototype.supports = function (obj) { return checkIfMongoCursor(obj); }; | ||
return MongoCursorDifferFactory; | ||
}(default_iterable_differ_1.DefaultIterableDifferFactory)); | ||
exports.MongoCursorDifferFactory = MongoCursorDifferFactory; | ||
}()); | ||
var trackById = function (index, item) { return item._id; }; | ||
@@ -50,3 +42,3 @@ /** | ||
*/ | ||
var MongoCursorDiffer = (function (_super) { | ||
export var MongoCursorDiffer = (function (_super) { | ||
__extends(MongoCursorDiffer, _super); | ||
@@ -61,3 +53,2 @@ function MongoCursorDiffer(cdRef, obsFactory) { | ||
this._forSize = 0; | ||
this._zone = Zone.current; | ||
this._obsFactory = obsFactory; | ||
@@ -168,3 +159,3 @@ } | ||
var change = changes_1[_i]; | ||
if (change instanceof mongo_cursor_observer_1.AddChange) { | ||
if (change instanceof AddChange) { | ||
var add = this._createChangeRecord(change.index, null, change.item); | ||
@@ -175,3 +166,3 @@ this._inserted.push(add); | ||
} | ||
if (change instanceof mongo_cursor_observer_1.MoveChange) { | ||
if (change instanceof MoveChange) { | ||
var move = this._createChangeRecord(change.toIndex, change.fromIndex, change.item); | ||
@@ -181,3 +172,3 @@ this._moved.push(move); | ||
} | ||
if (change instanceof mongo_cursor_observer_1.RemoveChange) { | ||
if (change instanceof RemoveChange) { | ||
var remove = this._createChangeRecord(null, change.index, change.item); | ||
@@ -188,3 +179,3 @@ this._removed.push(remove); | ||
} | ||
if (change instanceof mongo_cursor_observer_1.UpdateChange) { | ||
if (change instanceof UpdateChange) { | ||
this._updated.push(this._createChangeRecord(change.index, null, change.item)); | ||
@@ -195,3 +186,3 @@ } | ||
MongoCursorDiffer.prototype._createChangeRecord = function (currentIndex, prevIndex, item) { | ||
var record = new default_iterable_differ_1.CollectionChangeRecord(item, trackById); | ||
var record = new CollectionChangeRecord(item, trackById); | ||
record.currentIndex = currentIndex; | ||
@@ -202,3 +193,2 @@ record.previousIndex = prevIndex; | ||
return MongoCursorDiffer; | ||
}(default_iterable_differ_1.DefaultIterableDiffer)); | ||
exports.MongoCursorDiffer = MongoCursorDiffer; | ||
}(DefaultIterableDiffer)); |
@@ -29,3 +29,2 @@ import { EventEmitter } from '@angular/core'; | ||
private _debounceMs; | ||
private _added; | ||
private _lastChanges; | ||
@@ -39,3 +38,3 @@ private _cursor; | ||
subscribe(events: any): any; | ||
lastChanges: (AddChange | MoveChange | UpdateChange | RemoveChange)[]; | ||
readonly lastChanges: (AddChange | MoveChange | UpdateChange | RemoveChange)[]; | ||
destroy(): void; | ||
@@ -42,0 +41,0 @@ private _processCursor(cursor); |
'use strict'; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var core_1 = require('@angular/core'); | ||
var lang_1 = require('@angular/core/src/facade/lang'); | ||
var cursor_handle_1 = require('./cursor_handle'); | ||
var utils_1 = require('./utils'); | ||
var AddChange = (function () { | ||
import { EventEmitter } from '@angular/core'; | ||
import { check, gZone, g, debounce, noop } from './utils'; | ||
import { CursorHandle } from './cursor_handle'; | ||
export var AddChange = (function () { | ||
function AddChange(index, item) { | ||
@@ -18,4 +12,3 @@ this.index = index; | ||
}()); | ||
exports.AddChange = AddChange; | ||
var UpdateChange = (function () { | ||
export var UpdateChange = (function () { | ||
function UpdateChange(index, item) { | ||
@@ -27,4 +20,3 @@ this.index = index; | ||
}()); | ||
exports.UpdateChange = UpdateChange; | ||
var MoveChange = (function () { | ||
export var MoveChange = (function () { | ||
function MoveChange(fromIndex, toIndex) { | ||
@@ -36,4 +28,3 @@ this.fromIndex = fromIndex; | ||
}()); | ||
exports.MoveChange = MoveChange; | ||
var RemoveChange = (function () { | ||
export var RemoveChange = (function () { | ||
function RemoveChange(index) { | ||
@@ -44,3 +35,2 @@ this.index = index; | ||
}()); | ||
exports.RemoveChange = RemoveChange; | ||
/** | ||
@@ -51,3 +41,3 @@ * Class that does a background work of observing | ||
*/ | ||
var MongoCursorObserver = (function (_super) { | ||
export var MongoCursorObserver = (function (_super) { | ||
__extends(MongoCursorObserver, _super); | ||
@@ -58,7 +48,6 @@ function MongoCursorObserver(cursor, _debounceMs) { | ||
this._debounceMs = _debounceMs; | ||
this._added = []; | ||
this._lastChanges = []; | ||
this._ngZone = utils_1.g.Zone.current; | ||
this._ngZone = g.Zone.current; | ||
this._isSubscribed = false; | ||
utils_1.check(cursor, Match.Where(MongoCursorObserver.isCursor)); | ||
check(cursor, Match.Where(MongoCursorObserver.isCursor)); | ||
this._cursor = cursor; | ||
@@ -104,3 +93,3 @@ } | ||
var hCurObserver = this._startCursorObserver(cursor); | ||
return new cursor_handle_1.CursorHandle(hCurObserver); | ||
return new CursorHandle(hCurObserver); | ||
}; | ||
@@ -119,3 +108,3 @@ MongoCursorObserver.prototype._startCursorObserver = function (cursor) { | ||
var scheduleEmit = function () { | ||
return _this._ngZone.scheduleMacroTask('emit', callEmit, null, lang_1.noop); | ||
return _this._ngZone.scheduleMacroTask('emit', callEmit, null, noop); | ||
}; | ||
@@ -125,3 +114,3 @@ var init = false; | ||
task.invoke(); | ||
_this._ngZone.run(lang_1.noop); | ||
_this._ngZone.run(noop); | ||
init = true; | ||
@@ -131,6 +120,6 @@ }; | ||
if (this._debounceMs) { | ||
emit = utils_1.debounce(function (task) { return runTask(task); }, this._debounceMs, scheduleEmit); | ||
emit = debounce(function (task) { return runTask(task); }, this._debounceMs, scheduleEmit); | ||
} | ||
else { | ||
var initAdd_1 = utils_1.debounce(function (task) { return runTask(task); }, 0, scheduleEmit); | ||
var initAdd_1 = debounce(function (task) { return runTask(task); }, 0, scheduleEmit); | ||
emit = function () { | ||
@@ -147,3 +136,3 @@ // This is for the case when cursor.observe | ||
} | ||
return utils_1.gZone.run(function () { return cursor.observe({ | ||
return gZone.run(function () { return cursor.observe({ | ||
addedAt: function (doc, index) { | ||
@@ -185,3 +174,2 @@ var change = _this._addAt(doc, index); | ||
return MongoCursorObserver; | ||
}(core_1.EventEmitter)); | ||
exports.MongoCursorObserver = MongoCursorObserver; | ||
}(EventEmitter)); |
@@ -1,1 +0,4 @@ | ||
export declare const METEOR_PROVIDERS: Array<any>; | ||
import { Provider } from '@angular/core'; | ||
export declare const METEOR_PROVIDERS: Array<Provider>; | ||
export declare class MeteorModule { | ||
} |
'use strict'; | ||
var core_1 = require('@angular/core'); | ||
var mongo_cursor_differ_1 = require('./mongo_cursor_differ'); | ||
var change_detection_1 = require('@angular/core/src/change_detection/change_detection'); | ||
import { NgModule, IterableDiffers } from '@angular/core'; | ||
import { MongoCursorDifferFactory } from './mongo_cursor_differ'; | ||
function meteorProviders() { | ||
var providers = []; | ||
var factories = change_detection_1.defaultIterableDiffers.factories; | ||
if (factories) { | ||
factories.push(new mongo_cursor_differ_1.MongoCursorDifferFactory()); | ||
return [ | ||
IterableDiffers.extend([new MongoCursorDifferFactory()]) | ||
]; | ||
} | ||
export var METEOR_PROVIDERS = meteorProviders(); | ||
export var MeteorModule = (function () { | ||
function MeteorModule() { | ||
} | ||
providers.push(core_1.provide(core_1.IterableDiffers, { | ||
useValue: new core_1.IterableDiffers(factories) | ||
})); | ||
return providers; | ||
} | ||
exports.METEOR_PROVIDERS = meteorProviders(); | ||
MeteorModule = __decorate([ | ||
NgModule({ | ||
providers: METEOR_PROVIDERS | ||
}), | ||
__metadata('design:paramtypes', []) | ||
], MeteorModule); | ||
return MeteorModule; | ||
}()); |
@@ -12,5 +12,11 @@ export declare type CallbacksObject = { | ||
export declare const gZone: any; | ||
export declare const EJSON: any; | ||
export declare const check: any; | ||
export declare const Match: any; | ||
export declare function debounce(func: any, wait: any, onInit: any): (...args: any[]) => any; | ||
export declare function noop(): void; | ||
export declare function isListLikeIterable(obj: any): boolean; | ||
export declare function isArray(obj: any): boolean; | ||
export declare function isPresent(obj: any): boolean; | ||
export declare function isBlank(obj: any): boolean; | ||
export declare function isJsObject(o: any): boolean; | ||
export declare function getSymbolIterator(): string | symbol; |
'use strict'; | ||
exports.subscribeEvents = ['onReady', 'onError', 'onStop']; | ||
function isMeteorCallbacks(callbacks) { | ||
export var subscribeEvents = ['onReady', 'onError', 'onStop']; | ||
export function isMeteorCallbacks(callbacks) { | ||
return _.isFunction(callbacks) || isCallbacksObject(callbacks); | ||
} | ||
exports.isMeteorCallbacks = isMeteorCallbacks; | ||
// Checks if callbacks of {@link CallbacksObject} type. | ||
function isCallbacksObject(callbacks) { | ||
return callbacks && exports.subscribeEvents.some(function (event) { | ||
export function isCallbacksObject(callbacks) { | ||
return callbacks && subscribeEvents.some(function (event) { | ||
return _.isFunction(callbacks[event]); | ||
}); | ||
} | ||
exports.isCallbacksObject = isCallbacksObject; | ||
; | ||
exports.g = typeof global === 'object' ? global : | ||
export var g = typeof global === 'object' ? global : | ||
typeof window === 'object' ? window : | ||
typeof self === 'object' ? self : this; | ||
exports.gZone = exports.g.Zone.current; | ||
exports.EJSON = Package['ejson'].EJSON; | ||
exports.check = Package['check'].check; | ||
exports.Match = Package['check'].Match; | ||
function debounce(func, wait, onInit) { | ||
export var gZone = g.Zone.current; | ||
export var check = Package['check'].check; | ||
/* tslint:disable */ | ||
export var Match = Package['check'].Match; | ||
export function debounce(func, wait, onInit) { | ||
var timeout, result, data; | ||
@@ -36,4 +34,5 @@ var later = function (context, args) { | ||
} | ||
if (timeout) | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
} | ||
timeout = _.delay(later, wait, this, args); | ||
@@ -44,3 +43,42 @@ return result; | ||
} | ||
exports.debounce = debounce; | ||
; | ||
export function noop() { } | ||
export function isListLikeIterable(obj) { | ||
if (!isJsObject(obj)) | ||
return false; | ||
return isArray(obj) || | ||
(!(obj instanceof Map) && | ||
getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop | ||
} | ||
export function isArray(obj) { | ||
return Array.isArray(obj); | ||
} | ||
export function isPresent(obj) { | ||
return obj !== undefined && obj !== null; | ||
} | ||
export function isBlank(obj) { | ||
return obj === undefined || obj === null; | ||
} | ||
export function isJsObject(o) { | ||
return o !== null && (typeof o === 'function' || typeof o === 'object'); | ||
} | ||
var _symbolIterator = null; | ||
export function getSymbolIterator() { | ||
if (isBlank(_symbolIterator)) { | ||
if (isPresent(g.Symbol) && isPresent(Symbol.iterator)) { | ||
_symbolIterator = Symbol.iterator; | ||
} | ||
else { | ||
// es6-shim specific logic | ||
var keys = Object.getOwnPropertyNames(Map.prototype); | ||
for (var i = 0; i < keys.length; ++i) { | ||
var key = keys[i]; | ||
if (key !== 'entries' && key !== 'size' && | ||
Map.prototype[key] === Map.prototype['entries']) { | ||
_symbolIterator = key; | ||
} | ||
} | ||
} | ||
} | ||
return _symbolIterator; | ||
} |
@@ -7,21 +7,21 @@ 'use strict'; | ||
import {TaskList} from '/client/components'; | ||
import template from './app.component.html'; | ||
import {Observable} from 'rxjs'; | ||
import 'rxjs/add/operator/debounce'; | ||
@Component({ | ||
selector: 'app', | ||
template: template, | ||
directives: [TaskList] | ||
template: template | ||
}) | ||
export class Todos { | ||
todoCount = Tasks.find({ checked: false}) | ||
.debounce(() => Observable.interval(50)) | ||
.map(tasks => tasks.length); | ||
addTask(text: string) { | ||
Meteor.call('tasks.addTask', text); | ||
} | ||
get todoCount() { | ||
return Tasks.find({ | ||
checked: false | ||
}).count(); | ||
} | ||
} |
@@ -11,5 +11,7 @@ 'use strict'; | ||
import {MeteorModule} from 'angular2-meteor'; | ||
import {METEOR_PROVIDERS} from 'angular2-meteor'; | ||
import {Todos} from './app.component'; | ||
import {TaskList} from '/client/components'; | ||
import {TaskView} from '../imports/components'; | ||
@@ -19,4 +21,5 @@ enableProdMode(); | ||
@NgModule({ | ||
imports: [BrowserModule, MeteorModule, FormsModule], | ||
declarations: [Todos], | ||
imports: [BrowserModule, FormsModule], | ||
declarations: [Todos, TaskList, TaskView], | ||
providers: METEOR_PROVIDERS, | ||
bootstrap: [Todos] | ||
@@ -23,0 +26,0 @@ }) |
@@ -5,6 +5,4 @@ 'use strict'; | ||
import {TaskView} from '../../imports/components'; | ||
import {MeteorReactive} from 'angular2-meteor'; | ||
import {MeteorComponent} from 'angular2-meteor'; | ||
import {Tasks} from '../../tasks'; | ||
@@ -16,9 +14,10 @@ | ||
import {ObservableCursor} from 'meteor-rxjs'; | ||
@Component({ | ||
selector: 'task-list', | ||
template: template, | ||
directives: [TaskView] | ||
template: template | ||
}) | ||
export class TaskList extends MeteorComponent implements OnChanges { | ||
tasks: Mongo.Cursor<Task>; | ||
export class TaskList extends MeteorReactive implements OnChanges { | ||
tasks: ObservableCursor<Task>; | ||
@Input() hideCompleted: boolean = false; | ||
@@ -25,0 +24,0 @@ isLoading: boolean; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
import {MeteorComponent} from 'angular2-meteor'; | ||
import {MeteorReactive} from 'angular2-meteor'; | ||
@@ -17,3 +17,3 @@ import style from './task.component.less'; | ||
}) | ||
export class TaskView extends MeteorComponent { | ||
export class TaskView extends MeteorReactive { | ||
@Input() task: Task; | ||
@@ -20,0 +20,0 @@ |
{ | ||
"private": true, | ||
"dependencies": { | ||
"@angular/common": "^2.0.0-rc.5", | ||
"@angular/compiler": "^2.0.0-rc.5", | ||
"@angular/core": "^2.0.0-rc.5", | ||
"@angular/common": "^2.0.0", | ||
"@angular/compiler": "^2.0.0", | ||
"@angular/core": "^2.0.0", | ||
"@angular/forms": "^0.3.0", | ||
"@angular/platform-browser": "^2.0.0-rc.5", | ||
"@angular/platform-browser-dynamic": "^2.0.0-rc.5", | ||
"@angular/platform-browser": "^2.0.0", | ||
"@angular/platform-browser-dynamic": "^2.0.0", | ||
"angular2-meteor": "file:../..", | ||
@@ -14,10 +14,14 @@ "angular2-meteor-polyfills": "^0.1.1", | ||
"es6-shim": "^0.35.0", | ||
"meteor-node-stubs": "^0.2.3", | ||
"meteor-rxjs": "https://github.com/Urigo/meteor-rxjs", | ||
"npm-git-install": "^0.2.0", | ||
"reflect-metadata": "0.1.2", | ||
"rxjs": "5.0.0-beta.6", | ||
"rxjs": "5.0.0-beta.12", | ||
"zone.js": "^0.6.10" | ||
}, | ||
"devDependencies": { | ||
"linklocal": "^2.6.0" | ||
"linklocal": "^2.6.0", | ||
"typescript": "^2.0.2" | ||
}, | ||
"license": "MIT" | ||
} |
'use strict'; | ||
import {Meteor} from 'meteor/meteor'; | ||
import {Mongo} from "meteor/mongo"; | ||
import {Mongo} from 'meteor/mongo'; | ||
export let Tasks = new Mongo.Collection<Task>('tasks'); | ||
import {MongoObservable} from 'meteor-rxjs'; | ||
export let Tasks = new MongoObservable.Collection<Task>('tasks'); | ||
Meteor.methods({ | ||
@@ -15,3 +17,3 @@ 'tasks.addTask': function(text: string) { | ||
createdAt: new Date() | ||
}); | ||
}) | ||
}, | ||
@@ -26,3 +28,3 @@ | ||
Tasks.update(taskId, { | ||
$set: {checked: setChecked} | ||
$set: { checked: setChecked } | ||
}); | ||
@@ -34,3 +36,3 @@ }, | ||
Tasks.update(taskId, { | ||
$set: {private: setToPrivate} | ||
$set: { private: setToPrivate } | ||
}); | ||
@@ -37,0 +39,0 @@ } |
@@ -1,8 +0,7 @@ | ||
export * from './patch'; | ||
/// <reference path="../typings/index.d.ts" /> | ||
export * from './zone_utils'; | ||
export * from './mongo_cursor_observer'; | ||
export * from './mongo_cursor_differ'; | ||
export * from './meteor_component'; | ||
export * from './meteor_reactive'; | ||
export * from './providers'; | ||
export * from './data_observer'; | ||
export * from './meteor_module'; | ||
export * from './minimongo-observable/index'; |
'use strict'; | ||
import {ChangeDetectorRef} from '@angular/core'; | ||
import { | ||
DefaultIterableDifferFactory, | ||
CollectionChangeRecord, | ||
DefaultIterableDiffer | ||
} from '@angular/core/src/change_detection/differs/default_iterable_differ'; | ||
IterableDifferFactory, | ||
DefaultIterableDiffer, | ||
ChangeDetectorRef | ||
} from '@angular/core'; | ||
import {Subscription} from 'rxjs/Subscription'; | ||
import { | ||
@@ -19,6 +20,2 @@ MongoCursorObserver, | ||
import {Subscription} from 'rxjs/Subscription'; | ||
import {gZone} from './utils'; | ||
export interface ObserverFactory { | ||
@@ -47,3 +44,3 @@ create(cursor: Object): Object; | ||
// differ it needs to create and use for the current collection. | ||
export class MongoCursorDifferFactory extends DefaultIterableDifferFactory { | ||
export class MongoCursorDifferFactory implements IterableDifferFactory { | ||
supports(obj: Object): boolean { return checkIfMongoCursor(obj); } | ||
@@ -76,3 +73,2 @@ | ||
private _sub: Subscription; | ||
private _zone = Zone.current; | ||
@@ -79,0 +75,0 @@ constructor(cdRef: ChangeDetectorRef, obsFactory: ObserverFactory) { |
@@ -5,8 +5,5 @@ 'use strict'; | ||
import {noop} from '@angular/core/src/facade/lang'; | ||
import {check, gZone, g, debounce, noop} from './utils'; | ||
import {CursorHandle} from './cursor_handle'; | ||
import {EJSON, check, gZone, g, debounce} from './utils'; | ||
export class AddChange { | ||
@@ -41,3 +38,2 @@ constructor(public index: number, public item: any) {} | ||
export class MongoCursorObserver extends EventEmitter<MongoDocChange[]> { | ||
private _added: Array<AddChange> = []; | ||
private _lastChanges: Array<MongoDocChange> = []; | ||
@@ -54,3 +50,3 @@ private _cursor: Mongo.Cursor<any>; | ||
constructor(cursor: Mongo.Cursor<any>, | ||
private _debounceMs: number = 50) { | ||
private _debounceMs = 50) { | ||
super(); | ||
@@ -140,3 +136,3 @@ check(cursor, Match.Where(MongoCursorObserver.isCursor)); | ||
runTask(scheduleEmit()); | ||
} | ||
}; | ||
} | ||
@@ -143,0 +139,0 @@ |
'use strict'; | ||
import {provide, IterableDiffers} from '@angular/core'; | ||
import {NgModule, Provider, IterableDiffers} from '@angular/core'; | ||
import {MongoCursorDifferFactory} from './mongo_cursor_differ'; | ||
import {defaultIterableDiffers} from '@angular/core/src/change_detection/change_detection'; | ||
function meteorProviders() { | ||
let providers = []; | ||
return [ | ||
IterableDiffers.extend([new MongoCursorDifferFactory()]) | ||
]; | ||
} | ||
let factories = defaultIterableDiffers.factories; | ||
if (factories) { | ||
factories.push(new MongoCursorDifferFactory()); | ||
} | ||
providers.push(provide(IterableDiffers, { | ||
useValue: new IterableDiffers(factories) | ||
})); | ||
export const METEOR_PROVIDERS: Array<Provider> = meteorProviders(); | ||
return providers; | ||
} | ||
export const METEOR_PROVIDERS: Array<any> = meteorProviders(); | ||
@NgModule({ | ||
providers: METEOR_PROVIDERS | ||
}) | ||
export class MeteorModule {} |
@@ -32,6 +32,5 @@ 'use strict'; | ||
export const EJSON = Package['ejson'].EJSON; | ||
export const check = Package['check'].check; | ||
/* tslint:disable */ | ||
export const Match = Package['check'].Match; | ||
@@ -51,3 +50,5 @@ | ||
} | ||
if (timeout) clearTimeout(timeout); | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
} | ||
timeout = _.delay(later, wait, this, args); | ||
@@ -60,1 +61,47 @@ | ||
}; | ||
export function noop() {} | ||
export function isListLikeIterable(obj: any): boolean { | ||
if (!isJsObject(obj)) return false; | ||
return isArray(obj) || | ||
(!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v] | ||
getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop | ||
} | ||
export function isArray(obj: any): boolean { | ||
return Array.isArray(obj); | ||
} | ||
export function isPresent(obj: any): boolean { | ||
return obj !== undefined && obj !== null; | ||
} | ||
export function isBlank(obj: any): boolean { | ||
return obj === undefined || obj === null; | ||
} | ||
export function isJsObject(o: any): boolean { | ||
return o !== null && (typeof o === 'function' || typeof o === 'object'); | ||
} | ||
declare var Symbol: any; | ||
var _symbolIterator: any = null; | ||
export function getSymbolIterator(): string|symbol { | ||
if (isBlank(_symbolIterator)) { | ||
if (isPresent((<any>g).Symbol) && isPresent(Symbol.iterator)) { | ||
_symbolIterator = Symbol.iterator; | ||
} else { | ||
// es6-shim specific logic | ||
var keys = Object.getOwnPropertyNames(Map.prototype); | ||
for (var i = 0; i < keys.length; ++i) { | ||
var key = keys[i]; | ||
if (key !== 'entries' && key !== 'size' && | ||
(Map as any).prototype[key] === Map.prototype['entries']) { | ||
_symbolIterator = key; | ||
} | ||
} | ||
} | ||
} | ||
return _symbolIterator; | ||
} |
{ | ||
"name": "angular2-meteor", | ||
"version": "0.7.0-beta.1", | ||
"version": "0.7.0-beta.2", | ||
"keywords": [ | ||
@@ -16,4 +16,4 @@ "angular", | ||
}, | ||
"main": "dist/main.js", | ||
"browser": "dist/index.js", | ||
"main": "dist/bundles/main.umd.js", | ||
"browser": "dist/bundles/index.umd.js", | ||
"typings": "dist/index.d.ts", | ||
@@ -28,34 +28,33 @@ "homepage": "http://www.angular-meteor.com", | ||
"prebuild": "npm run typings && npm run lint", | ||
"build": "npm run build-only", | ||
"build-only": "tsc || echo not ok", | ||
"build": "npm run build-only && npm run bundle", | ||
"prepublish": "npm run build", | ||
"lint": "tslint modules/**/*.ts", | ||
"test": "./run_tests.sh", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
"rollup:browser": "rollup -i ./dist/index.js -o ./dist/bundles/index.umd.js -n ng.meteor -c rollup.config.js", | ||
"rollup:main": "rollup -i ./dist/main.js -o ./dist/bundles/main.umd.js -n ng.meteor -c rollup.config.js", | ||
"bundle": "npm run rollup:browser && npm run rollup:main" | ||
}, | ||
"peerDependencies": { | ||
"@angular/core": "^2.0.0-rc.5", | ||
"@angular/core": "^2.0.0", | ||
"angular2-meteor-polyfills": "^0.1.1" | ||
}, | ||
"devDependencies": { | ||
"@angular/core": "^2.0.0-rc.5", | ||
"@angular/common": "^2.0.0-rc.5", | ||
"@angular/compiler": "^2.0.0-rc.5", | ||
"@angular/common": "^2.0.0", | ||
"@angular/compiler": "^2.0.0", | ||
"@angular/core": "^2.0.0", | ||
"angular2-meteor-polyfills": "^0.1.1", | ||
"conventional-changelog-cli": "^1.2.0", | ||
"es6-shim": "^0.35.0", | ||
"zone.js": "^0.6.12", | ||
"rxjs": "5.0.0-beta.6", | ||
"reflect-metadata": "^0.1.2", | ||
"ghooks": "^1.2.1", | ||
"validate-commit-msg": "^2.6.1", | ||
"conventional-changelog-cli": "^1.2.0", | ||
"rollup": "^0.35.9", | ||
"rollup-plugin-babel": "^2.6.1", | ||
"rxjs": "5.0.0-beta.11", | ||
"tsc": "^1.20150623.0", | ||
"tslint": "^3.6.0", | ||
"typescript": "^1.8.0", | ||
"typings": "^1.3.0" | ||
"typescript": "2.0.0", | ||
"typings": "^1.3.0", | ||
"zone.js": "^0.6.12" | ||
}, | ||
"config": { | ||
"ghooks": { | ||
"commit-msg": "validate-commit-msg" | ||
} | ||
}, | ||
"dependencies": { | ||
@@ -62,0 +61,0 @@ "lodash": "^4.14.0" |
@@ -64,12 +64,10 @@ # Angular2-Meteor [![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![Build Status](https://travis-ci.org/Urigo/angular2-meteor.svg?branch=master)](https://travis-ci.org/Urigo/angular2-meteor) [![Join the chat at https://gitter.im/Reactive-Extensions/RxJS](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Urigo/angular-meteor) | ||
The package contains `MeteorModule` module that has providers simplifing development of a Meteor app with Angular 2. | ||
The package contains `METEOR_PROVIDERS` providers that simplify development of a Meteor app with Angular 2. | ||
You can use Meteor collections in the same way as you would do in a regular Meteor app with the Blaze, | ||
the only thing required is to import and use `MeteorModule` from `angular2-meteor`. | ||
After, you you can iterate `Mongo.Cursor` objects with Angular 2.0's `ngFor`! | ||
You can use Mongo collections in the same way as you would do in a regular Meteor app with the Blaze, | ||
the only thing required is to import and use `METEOR_PROVIDERS` from `angular2-meteor`. | ||
After, you can iterate `Mongo.Cursor`s with Angular 2.0's `ngFor` as follows: | ||
Below is a valid Angular2-Meteor app: | ||
````ts | ||
import {MeteorModule, MeteorComponent} from 'angular2-meteor'; | ||
import {METEOR_PROVIDERS, MeteorReactive} from 'angular2-meteor'; | ||
@@ -85,3 +83,3 @@ const Parties = new Mongo.Collection('parties'); | ||
}) | ||
class Socially extends MeteorComponent { | ||
class Socially extends MeteorReactive { | ||
constructor() { | ||
@@ -94,3 +92,4 @@ this.subscribe('my-subscription'); | ||
@NgModule({ | ||
imports: [BrowserModule, MeteorModule], | ||
imports: [BrowserModule], | ||
providers: METEOR_PROVIDERS, | ||
declarations: [Socially], | ||
@@ -103,5 +102,8 @@ bootstrap: [Socially] | ||
```` | ||
`MeteorReactive` is a special utility class that does two things behind the scene for you: | ||
- releases Meteor and Mongo handlers on the destroy event; | ||
- runs Angular 2 zone on Meteor methods' callbacks with | ||
debouncing, i.e., reducing number of zone runs to minimun. | ||
`MeteorComponent` wraps major Meteor methods to do some work behind the scene (such as cleanup) for a component that extends it. | ||
You can read more about `MeteorComponent` in the [tutorial section] (http://www.angular-meteor.com/tutorials/socially/angular2/privacy-and-publish-subscribe-functions)! | ||
You can read more about `MeteorReactive` in the [tutorial section] (http://www.angular-meteor.com/tutorials/socially/angular2/privacy-and-publish-subscribe-functions)! | ||
@@ -108,0 +110,0 @@ At this moment, you are almost set to create awesome apps backed by the power of Angular 2 and Meteor! |
{ | ||
"compilerOptions": { | ||
"experimentalDecorators": true, | ||
"module": "commonjs", | ||
"module": "es2015", | ||
"target": "es5", | ||
@@ -12,9 +12,11 @@ "noImplicitAny": false, | ||
"declaration": true, | ||
"noEmitHelpers": true, | ||
"outDir": "./dist", | ||
"rootDir": "./modules" | ||
"rootDir": "./modules", | ||
"lib": ["es2015", "dom"], | ||
"skipLibCheck": true | ||
}, | ||
"files": [ | ||
"modules/index.ts", | ||
"modules/main.ts", | ||
"typings/index.d.ts" | ||
"modules/main.ts" | ||
], | ||
@@ -21,0 +23,0 @@ "exclude": [ |
@@ -35,3 +35,3 @@ { | ||
"no-shadowed-variable": true, | ||
"no-string-literal": true, | ||
"no-string-literal": false, | ||
"no-switch-case-fall-through": true, | ||
@@ -38,0 +38,0 @@ "no-trailing-whitespace": true, |
{ | ||
"globalDependencies": { | ||
"es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504", | ||
"meteor": "github:meteor-typings/meteor/1.3#955b89a4e2af892d1736bc570b490a97e860d5b7", | ||
@@ -5,0 +4,0 @@ "mocha": "registry:dt/mocha#2.2.5+20160720003353", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
131380
3193
217
64
1