Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <link href="//cdn.jsdelivr.net/picnicss/4.1.1/picnic.min.css" rel="stylesheet">
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="app">
    <clock1></clock1>
    <clock2></clock2>
  </div>
  <div class="hide">
    <div id="timer">
      <b>Time: </b>
      <time></time>
    </div>
  </div>
  <script src="//rawgit.com/magnumjs/mag.js/master/dist/mag.0.22.8.min.js"></script>
  <script src="//rawgit.com/magnumjs/mag.js/master/dist/mag.addons.0.21.min.js"></script>
</body>
</html>
 
li:empty, .hide {
  display:none;
}
 
mag.composer = function(id, comp, oprops) {
  var containerModule = {
    controller: function() {
     comp.controller.apply(this, arguments);
    },
    view: function() {
      comp.view.apply(this, arguments);
    }
  };
  return mag.create(id, containerModule, oprops);
};
//Component:
var Timer = {
  controller: function(props){
    this.willupdate = function(){
      console.log('i will up');
    };
  },
  view: function(state, props) {
    state.time = props.time;
  }
};
var compose = mag.composer('timer', Timer, {});
//Parent:
mag.module('app', {
  view: function(state) {
    state.clock1 = compose({
      time: Date.now()
    });
    state.clock2 = compose({
      time: String(Date())
    });
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers