Skip to content

Instantly share code, notes, and snippets.

View canonic-epicure's full-sized avatar
💭
Well-typed API for the world

Nickolay Platonov canonic-epicure

💭
Well-typed API for the world
View GitHub Profile
// ================================================
// Using CommonJS modules in Joose - basic
Module('Graphic.Circle', function (module) {
// this == Graphic.Circle
// module == Graphic.Circle
var puts = require('sys').puts
// ================================================
// Using CommonJS modules in Joose - with dependencies
Module('Graphic.Circle', {
require : [ './some/commonjs/module1.js', './some/commonjs/module2.js' ],
use : {
'Some.Joose.Role' : 0.01,
// ================================================
// Joose classes, depending on Joose classes only
Class('Graphic.Circle', {
does : {
'Some.Joose.Role' : 0.01,
},
Class('DataStore.Sync', {
methods : {
log : function () {
var response = // somehow get the response from logging operation
return response
},
Class('DataStore.Async', {
trait : JooseX.CPS,
continued : {
methods : {
log : function () {
Class('FileSystem', {
trait : JooseX.CPS,
continued : {
methods : {
save : function (data) {
Role('Method.Feature.Decorated')
Class('Method.Special', {
meta : JooseX.Meta.Class,
isa : Joose.Managed.Property.MethodModifier.Put,
does : Method.Feature.Decorated
})
Class('Class.With.Decorated.Methods', {
trait : JooseX.Class.MethodLabels,
methods : {
method1 : function () {
...
// require.paths.unshift('/us/local/lib/jsan');
require.paths.unshift('/home/nickolay/Playground/nodejs');
require('Task/Joose/NodeJS');
var sys = require('sys');
Joose.Module('SuperStuff', {
// the following library is available in the path unshifted above
// require.paths.unshift('/us/local/lib/jsan');
require.paths.unshift('/home/nickolay/Playground/nodejs');
require('Task/Joose/NodeJS');
var sys = require('sys');
Joose.Module('SuperStuff', {
// the following library is available in the path unshifted above