Skip to content
Maxime LUCE edited this page Feb 25, 2014 · 2 revisions

Introduction

KoMVVM have to be used with an AMD library like require.js. We think that AMD Loading is a necessary thing in modern javascript application developpement, that's why we are providing KoMVVM as an AMD optimized library.

We are thinking at providing a built version in next releases.

Configure require.js or almond

// app/main.js
require.config({
    paths: {
        knockout: 'path/to/knockout',
        underscore: 'path/to/underscore',
        koutils: 'path/to/koutils',
        komvvm: 'path/to/komvvm'
    }
});

Use any modules in your view models

// app/viewmodel1.js
define(["komvvm/commands"], function(commands) {
    var command = new commands.AsynCommand({
        canExecute: function(isExecuting) { return !isExecuting && /* ... */; },
        execute: function(complete) { 
            // ...
            complete();
        }
    });
});

Clone this wiki locally