add grootprovider

This commit is contained in:
Pete Richards 2016-06-17 17:05:05 -07:00
parent a63e053399
commit d475d767d5
3 changed files with 50 additions and 5 deletions

View File

@ -31,12 +31,14 @@
<script type="text/javascript"> <script type="text/javascript">
require(['main'], function (mct) { require(['main'], function (mct) {
require([ require([
'./tutorials/grootprovider/groots',
'./tutorials/todo/todo', './tutorials/todo/todo',
'./tutorials/todo/bundle', './tutorials/todo/bundle',
'./example/imagery/bundle', './example/imagery/bundle',
'./example/eventGenerator/bundle', './example/eventGenerator/bundle',
'./example/generator/bundle' './example/generator/bundle',
], function (todoPlugin) { ], function (grootify, todoPlugin) {
grootify(mct);
todoPlugin(mct); todoPlugin(mct);
mct.start(); mct.start();
}) })

View File

@ -80,11 +80,10 @@ var GrootProvider = {
} }
}; };
MCT.objects.addRoot(ROOT_KEY); mct.Objects.addRoot(ROOT_KEY);
MCT.objects.addProvider('groot', GrootProvider); mct.Objects.addProvider('groot', GrootProvider);
MCT.run();
``` ```
### Making a custom provider: ### Making a custom provider:

View File

@ -0,0 +1,44 @@
define(function () {
return function grootPlugin(mct) {
var ROOT_KEY = {
namespace: 'groot',
identifier: 'groot'
};
var GROOT_ROOT = {
name: 'I am groot',
type: 'folder',
composition: [
{
namespace: 'groot',
identifier: 'arms'
},
{
namespace: 'groot',
identifier: 'legs'
},
{
namespace: 'groot',
identifier: 'torso'
}
]
};
var GrootProvider = {
get: function (key) {
if (key.identifier === 'groot') {
return Promise.resolve(GROOT_ROOT);
}
return Promise.resolve({
name: 'Groot\'s ' + key.identifier
});
}
};
mct.Objects.addRoot(ROOT_KEY);
mct.Objects.addProvider('groot', GrootProvider);
return mct;
};
});