Skip to content

Instantly share code, notes, and snippets.

@alistair
Created June 4, 2015 21:37
Show Gist options
  • Save alistair/4dbc225a2cf5c8c19edd to your computer and use it in GitHub Desktop.
Save alistair/4dbc225a2cf5c8c19edd to your computer and use it in GitHub Desktop.
portlets in SPAs
// Admin App Host application
require('something') // we need to force load all modules, could this be by convention?
var Registration = require('register');
var links = Registration.get();
for(var i in links)
{
print("<a href='+i.url+' >' + i.title +'</a>
}
/*
The smae idea could be applied to react. just replace a the url with a function which happens to return a component
something like
*/
require('something') // we need to force load all modules, could this be by convention?
var Registration = require('register');
var links = Registration.get(); { id: ..., ; title: ...., function: ....}
var MainApplicationWindow = React.createClass({
var subComponents = links.map(function (item) {
return (
<div id={item.id}>
<h1>{item.title}</h1>
{item.function()}
</div>
);
return {
<div>
{subComponents}
</div>
}
}
exports = MainApplicationWindow
var Registration = reguire('register');
Registration.register('ats', 'Manage Ats', '//hello.world/api');
var registrations = [];
var register = function(id, title, url) {
registrations.push({ 'id': id, 'title': title, 'url': url})
}
var get = function() { return registrations; };
exports = { register: register, getRegistrations: get };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment