Skip to content

Instantly share code, notes, and snippets.

realm.module("app.services.ToDo", ["realm.router.BridgeRequest"], function(BridgeRequest) {
var $_exports;
$_exports = {
'add': function() {
return BridgeRequest.connect("app.services.ToDo", "add", arguments)
}
}
return $_exports;
});
"use realm bridge";
class ToDo {
static add(name) {}
}
export Todo;
"use realm";
import MainController, LoginController from app.controllers;
import User from models;
import lodash as _ from app.utils;
"use realm";
class Controller {
}
export Controller;
"use realm bridge"
import request from app.utils;
class GoogleBlog {
static getFeed(value) {
return new Promise(function(resolve, reject) {
request.get({
url: "https://ajax.googleapis.com/ajax/services/feed/find?v=1.0",
json: true,
qs: {
realm.module("app.blogs.GoogleFeed", ["app.utils.request"], function(request) {
var $_exports;
class GoogleBlog {
// code here
}
$_exports = GoogleBlog;
return $_exports;
});
realm.module("app.blogs.GoogleFeed", ["realm.router.BridgeRequest"], function(BridgeRequest) {
var $_exports;
$_exports = {
'getFeed': function() {
return BridgeRequest.connect("app.blogs.GoogleFeed", "getFeed", arguments)
}
}
return $_exports;
});
@nchanged
nchanged / registration_flow_ promises.js
Last active July 26, 2016 07:43
Registration Flow (promises)
let pwd, email, user;
UserFlow.validateEmail(email)
.then(UserFlow.checkUserExists) // Check if user exists
.then(function(existingUser){ // Spitting custom exception
if( existingUser ){
throw Error('User exists')
}
}).then(() => {
return UserFlow.hashPassword(pwd); // Hash password
}).then((hashedPwd)=>{
const UserFlow = {
fetchUser : (criteria) => {
return User.find(criteria).first() // Fetching a record
},
checkUserExists : (email) => {
return this.fetchUser({email : email});
}
}
class MyChain {
setFoo() {
// I am the first one. And i set this.foo = "foo1"
return "foo1";
}
setBar() {
// I am the second one, and i have "this.foo" at my disposal
// And i set this.bar = "bar1"
return "bar1";
}