Skip to content

Instantly share code, notes, and snippets.

View pnmcosta's full-sized avatar
🥷
coding remotely

Pedro Maia Costa pnmcosta

🥷
coding remotely
View GitHub Profile
@pnmcosta
pnmcosta / totaljs-promise-schema.js
Last active September 30, 2017 15:06
Total.js - Using Promise to get schema objects
NEWSCHEMA('Form').make(function (schema) {
schema.define('contact', 'FormContact', true);
schema.define('deal', 'FormDeal', true);
schema.addWorkflow('submit', function (error, model, options, callback, controller) {
Promise.all([getDealById(options.deal_id), getContactById(options.contact_id)])
.then(function (values) {
let valid = (values[0] && value[1]); // 0 = getDealById, 1 = getContactById
if (!valid) {
error.push('deal', 'not found.');
@pnmcosta
pnmcosta / brunch.commonjs.module.options.js
Last active April 3, 2017 18:50
Example CommonJS Module Wrapped by Brunch with options, private and public methods and properties
/**
* Example CommonJS Module Wrapped by Brunch with options, private and public methods
* Usage with defaults: require("brunch.commonjs.options.module")()
* Usage with options: require("brunch.commonjs.options.module")({myOptionName:false})
*/
"use strict";
// require's and constants
const $ = require("jquery");