mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
WIP
WIP WIP WIP WIP WIP WIP: Remove trailing newlines WIP WIP WIP WIP WIP WIP WIP WIP: All tests pass WIP WIP WIP
This commit is contained in:
@@ -15,11 +15,11 @@ interface CustomScope extends angular.meteor.IScope {
|
||||
todos: angular.meteor.AngularMeteorCollection<ITodo>;
|
||||
stickyTodos: angular.meteor.AngularMeteorCollection<ITodo>;
|
||||
notAutoTodos: angular.meteor.AngularMeteorCollection<ITodo>;
|
||||
|
||||
|
||||
todo: ITodo;
|
||||
todoNotAuto: TodoAngularMeteorObject;
|
||||
todoSubscribed: TodoAngularMeteorObject;
|
||||
|
||||
|
||||
save: (todo: ITodo) => void;
|
||||
saveAll: () =>void;
|
||||
autoSave: (todo: ITodo) => void;
|
||||
@@ -36,7 +36,7 @@ var app = angular.module('angularMeteorTestApp');
|
||||
app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor: angular.meteor.IMeteorService) => {
|
||||
// Bind all the todos to $scope.todos
|
||||
$scope.todos = $meteor.collection(Todos);
|
||||
|
||||
|
||||
$scope.sticky = true;
|
||||
// Bind all sticky todos to $scope.stickyTodos
|
||||
// Binds the query to $scope.sticky so that if it changes, Meteor will re-run the query and bind it
|
||||
@@ -44,46 +44,46 @@ app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor:
|
||||
$scope.stickyTodos = $meteor.collection<ITodo>(function(){
|
||||
return Todos.find({sticky: $scope.getReactively('sticky')});
|
||||
});
|
||||
|
||||
|
||||
// Bind without auto-save all todos to $scope.notAutoTodos
|
||||
$scope.notAutoTodos = $meteor.collection(Todos, false).subscribe("publicTodos");
|
||||
|
||||
|
||||
$scope.todoNotAuto = <TodoAngularMeteorObject>$meteor.object(Todos, 'TodoID', false);
|
||||
$scope.todoSubscribed = <TodoAngularMeteorObject>$meteor.object(Todos, 'TodoID').subscribe('todos');
|
||||
$scope.todo = $scope.todoNotAuto.getRawObject();
|
||||
$scope.todoNotAuto.reset();
|
||||
$scope.todoNotAuto.save($scope.todo).then((data) => { return data == 1; });;
|
||||
|
||||
|
||||
// todo might be an object like this {text: "Learn Angular", sticky: false}
|
||||
// or an array like this:
|
||||
// [{text: "Learn Angular", sticky: false}, {text: "Hello World", sticky: true}]
|
||||
|
||||
|
||||
$scope.save = function(todo) {
|
||||
$scope.notAutoTodos.save(todo);
|
||||
};
|
||||
|
||||
|
||||
$scope.saveAll = function() {
|
||||
$scope.notAutoTodos.save();
|
||||
};
|
||||
|
||||
|
||||
$scope.autoSave = function(todo) {
|
||||
$scope.todos.push(todo);
|
||||
};
|
||||
|
||||
|
||||
// todoId might be an string like this "WhrnEez5yBRgo4yEm"
|
||||
// or an array like this ["WhrnEez5yBRgo4yEm","gH6Fa4DXA3XxQjXNS"]
|
||||
$scope.remove = function(todoId) {
|
||||
$scope.notAutoTodos.remove(todoId);
|
||||
};
|
||||
|
||||
|
||||
$scope.removeAll = function() {
|
||||
$scope.notAutoTodos.remove();
|
||||
};
|
||||
|
||||
|
||||
$scope.removeAuto = function(todo) {
|
||||
$scope.todos.splice( $scope.todos.indexOf(todo), 1 );
|
||||
}
|
||||
|
||||
|
||||
$scope.toSticky = function(todo) {
|
||||
if (angular.isArray(todo)){
|
||||
angular.forEach(todo, function(object) {
|
||||
@@ -92,53 +92,53 @@ app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor:
|
||||
} else {
|
||||
todo.sticky = true;
|
||||
}
|
||||
|
||||
|
||||
$scope.stickyTodos.save(todo);
|
||||
};
|
||||
|
||||
|
||||
var todoObject = {name:'first todo'};
|
||||
var todosArray = [{name:'second todo'}, {name:'third todo'}];
|
||||
var todoSecondObject = {name:'forth todo'};
|
||||
|
||||
|
||||
$scope.todos.save(todoObject); // todos equals [{name:'first todo'}]
|
||||
|
||||
|
||||
$scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
|
||||
|
||||
|
||||
$scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
|
||||
// but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
|
||||
|
||||
|
||||
$scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
|
||||
|
||||
|
||||
$scope.todos.remove('firstTodoId'); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
|
||||
|
||||
|
||||
var todoIdsArray = ['secondTodoId', 'thirdTodoId'];
|
||||
$scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection
|
||||
|
||||
|
||||
$scope.todos.pop(); // removes only in scope
|
||||
|
||||
|
||||
$scope.todos.remove(); // syncs also in Meteor collection
|
||||
|
||||
|
||||
// Subscribe ->
|
||||
|
||||
|
||||
$meteor.subscribe('todos').then((subscriptionHandle) => {
|
||||
// Bind all the todos to $scope.todos
|
||||
$scope.todos = $meteor.collection(Todos);
|
||||
|
||||
|
||||
console.log($scope.todos + ' is ready');
|
||||
|
||||
|
||||
// You can use the subscription handle to stop the subscription if you want
|
||||
subscriptionHandle.stop();
|
||||
});
|
||||
|
||||
|
||||
$scope.subscribe('todos').then((subscriptionHandle) => {
|
||||
// Bind all the todos to $scope.books
|
||||
$scope.todos = $meteor.collection(Todos);
|
||||
|
||||
|
||||
console.log($scope.todos + ' is ready');
|
||||
|
||||
|
||||
// No need to stop the subscription, it will automatically close on scope destroy
|
||||
});
|
||||
|
||||
|
||||
$meteor.call<ITodo>('subscribe', $scope.todo._id, $scope.currentUser._id).then((data) => {
|
||||
// Handle success
|
||||
console.log('success subscribing', data.name);
|
||||
@@ -146,22 +146,22 @@ app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor:
|
||||
// Handle error
|
||||
console.log('failed', err);
|
||||
});
|
||||
|
||||
|
||||
if (!$scope.loggingIn) {
|
||||
$meteor.waitForUser();
|
||||
|
||||
|
||||
$meteor.requireUser();
|
||||
|
||||
|
||||
$meteor.requireValidUser(user => {
|
||||
return user.username == 'admin';
|
||||
});
|
||||
|
||||
|
||||
$meteor.loginWithPassword('user', 'password').then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.createUser({
|
||||
username:'moma',
|
||||
email:'example@gmail.com',
|
||||
@@ -172,45 +172,45 @@ app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor:
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.changePassword('old', 'new232f3').then(() => {
|
||||
console.log('Change password success');
|
||||
}, err => {
|
||||
console.log('Error changing password - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.forgotPassword({email: 'sample@gmail.com'}).then(() => {
|
||||
console.log('Success sending forgot password email');
|
||||
}, err => {
|
||||
console.log('Error sending forgot password email - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.resetPassword('tokenID', 'new232f3').then(() => {
|
||||
console.log('Reset password success');
|
||||
}, err => {
|
||||
console.log('Error resetting password - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.verifyEmail('tokenID').then(() => {
|
||||
console.log('Success verifying password ');
|
||||
}, err => {
|
||||
console.log('Error verifying password - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.logout().then(() => {
|
||||
console.log('Logout success');
|
||||
}, err => {
|
||||
console.log('logout error - ', err);
|
||||
});
|
||||
|
||||
|
||||
$meteor.logoutOtherClients().then(() => {
|
||||
console.log('Logout success');
|
||||
}, err => {
|
||||
console.log('logout error - ', err);
|
||||
});
|
||||
|
||||
|
||||
var loginWithOptions = {requestPermissions: ['email']};
|
||||
|
||||
|
||||
$meteor.loginWithFacebook({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
@@ -242,14 +242,14 @@ app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor:
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$meteor.autorun($scope, () => { console.log("Aurorun triggered."); });
|
||||
$meteor.getCollectionByName('collectionName');
|
||||
|
||||
|
||||
// requires meteor add mdg:camera
|
||||
$meteor.getPicture().then(function(data){
|
||||
$scope['picture'] = data;
|
||||
});
|
||||
|
||||
|
||||
$meteor.session('counter').bind($scope, 'counter');
|
||||
}]);
|
||||
|
||||
Vendored
+6
-6
@@ -51,7 +51,7 @@ declare module 'angular' {
|
||||
* @param definitions - Object containing `name` => `function` definition, where each name is a string and each function is the helper function. Should return a [MongoDB Cursor](http://docs.meteor.com/#/full/mongo_cursor)
|
||||
* @return This method returns this, which the the reactive context, in order to provide the ability to chain the logic.
|
||||
*/
|
||||
helpers(definitions : { [helperName : string] : () => Mongo.Cursor<any> }): IScope;
|
||||
helpers(definitions: { [helperName: string]: () => Mongo.Cursor<any> }): IScope;
|
||||
|
||||
/**
|
||||
* This method is a wrapper of Tracker.autorun and shares exactly the same API.
|
||||
@@ -61,7 +61,7 @@ declare module 'angular' {
|
||||
*
|
||||
* @param runFunc - The function to run. It receives one argument: the Computation object that will be returned.
|
||||
*/
|
||||
autorun(runFunc : () => void) : Tracker.Computation;
|
||||
autorun(runFunc: () => void): Tracker.Computation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ declare module 'angular' {
|
||||
* @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
|
||||
* - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
|
||||
*/
|
||||
collection<T>(collection: Mongo.Collection<T>|ReactiveResult|Function|(()=>T), autoClientSave?: boolean): AngularMeteorCollection<T>;
|
||||
collection<T>(collection: Mongo.Collection<T>|ReactiveResult|Function|(() => T), autoClientSave?: boolean): AngularMeteorCollection<T>;
|
||||
|
||||
/**
|
||||
* A service that wraps the Meteor collections to enable reactivity within AngularJS.
|
||||
@@ -87,7 +87,7 @@ declare module 'angular' {
|
||||
* - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
|
||||
* @param [updateCollection] - A collection object which will be used for updates (insert, update, delete).
|
||||
*/
|
||||
collection<T, U>(collection: Mongo.Collection<T>|ReactiveResult|Function|(()=>T), autoClientSave: boolean, updateCollection: Mongo.Collection<U>): AngularMeteorCollection2<T, U>;
|
||||
collection<T, U>(collection: Mongo.Collection<T>|ReactiveResult|Function|(() => T), autoClientSave: boolean, updateCollection: Mongo.Collection<U>): AngularMeteorCollection2<T, U>;
|
||||
|
||||
/**
|
||||
* A service that wraps a Meteor object to enable reactivity within AngularJS.
|
||||
@@ -307,7 +307,7 @@ declare module 'angular' {
|
||||
*
|
||||
* @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
|
||||
*/
|
||||
subscribe(subscriptionName:string): AngularMeteorObject<T>;
|
||||
subscribe(subscriptionName: string): AngularMeteorObject<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,7 +342,7 @@ declare module 'angular' {
|
||||
*
|
||||
* @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
|
||||
*/
|
||||
subscribe(subscriptionName:string): AngularMeteorCollection2<T, U>;
|
||||
subscribe(subscriptionName: string): AngularMeteorCollection2<T, U>;
|
||||
}
|
||||
|
||||
interface ILoginWithExternalService {
|
||||
|
||||
Reference in New Issue
Block a user