Skip to content

Instantly share code, notes, and snippets.

View cwatsonc's full-sized avatar
💭
Quarantining

cwatsonc

💭
Quarantining
View GitHub Profile
@cwatsonc
cwatsonc / client.js
Last active November 28, 2018 23:15
Async Loading using CommonJS require (module.js)
"use strict";
const myObject = require("./my_module.js");
console.log(`myObject is of type: ${typeof myObject}`);
//if myObject has async loaded resources it might not be ready for use
myObject();
@cwatsonc
cwatsonc / my_client.js
Last active November 21, 2018 21:41
Asynchronous Loading of a Module Nodejs CommonJS
"use strict";
const myObject = require("./my_module.js");
console.log('*****inside invocation*****');
console.log(`myObject is of type: ${typeof myObject}`);
console.log(`myObject.log is of type`, typeof myObject.log);
const p = myObject.log();
console.log(`the value of p is currently: ${p}`);
p.then(result => {
console.log(result);