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="container">
      <div></div>
    </div>
    <div id="timer">
      <b>Time: </b>
      <time></time>
    </div>
  </div>
  <script src="//rawgit.com/magnumjs/mag.js/master/dist/mag.0.22.11.min.js"></script>
</body>
</html>
 
/* MagJS Example: Higher-order Component */
//Composer: Higher-Order Component (HoC)
mag.composer = function(id, ComposedComponent, oprops) {
  var composed = mag.module(id, ComposedComponent, oprops);
  var hoc = {
    controller: function(props) {
      props.key = props.key || performance.now();
    },
    view: function(state, props) {
      state.div = composed(props);
    }
  };
  return mag.create('container', hoc, oprops);
};
//Component:
var Timer = {
  view: function(state, props) {
    state.time = props.time;
  }
};
var composer = mag.composer('timer', Timer);
mag.module('app', {
  view: function(state, props) {
    state.clock1 = composer({
      time: Date() + ""
    });
    state.clock2 = composer({
      time: Date.now()
    });
  }
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers