Create a gist now

Instantly share code, notes, and snippets.

@humphd /index.js
Last active Aug 29, 2015

MakeDrive Client API Example
// MakeDrive API -
var MakeDrive = require('./path/to/makedrive.js');
// fs API -
var fs = MakeDrive.fs();
// Use fs right away, with or without network
fs.mkdir('/project', function(err) {
if(err) throw err;
fs.writeFile('/project/index.html', '<p>Hello World!</p>', function(err) {
if(err) throw err;
// /project/index.html is now written to disk
// When you want to sync, get the fs' sync object
var sync = fs.sync;
// Listen for events you care about
sync.on('error', function(err) {
// There was an error during syncing
sync.on('connected', function() {
// Connected to sync server
sync.on('disconnected', function() {
// Disconnected from sync server
sync.on('syncing', function() {
// Syncing with server
sync.on('completed', function() {
// Completed syncing with server
// Connect to the server
// [Optional, if in manual mode] Request an upstream sync with the server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment