Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Reimplement custom element example #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions dist/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/app.js.map

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions dist/element.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/element.js.map

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import run from '@cycle/rxjs-run';
import { Observable } from 'rxjs/Observable';
import { makeDOMDriver, h } from '@cycle/dom';
import { Sandbox } from './components/sandbox/sandbox';
import { merge } from 'ramda';

class SandboxElement extends HTMLElement {
connectedCallback() {
let key = this.attributes.key.value;
const initialStore = { route: key, inputs: undefined };
function main( sources ) {
const sandbox = Sandbox( sources );
const sinks = {
DOM: sandbox.DOM,
store: sandbox.data.scan(merge, initialStore).startWith( initialStore ),
};
return sinks;
}

run(main, {
DOM: makeDOMDriver(this),
store: sources => sources.startWith( initialStore ),
});
}
}

customElements.define( 'rx-marbles', SandboxElement );
4 changes: 3 additions & 1 deletion test-custom-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<meta name="description" content="Learn, build, and test Rx functions on Observables">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RxMarbles: Interactive diagrams of Rx Observables</title>
<script src="dist/js/element.js"></script>
<script src="https://rawgit.com/webcomponents/custom-elements/master/src/native-shim.js"></script>
<script src="https://rawgit.com/webcomponents/custom-elements/master/custom-elements.min.js"></script>
<script src="dist/element.js"></script>
</head>
<body>
<!--[if lt IE 7]>
Expand Down
7 changes: 5 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ if (isProduction) {
}

module.exports = {
entry: './src/app.js',
entry: {
app: './src/app.js',
element: './src/element.js'
},

output: {
path: path.resolve(__dirname, 'dist'),
filename: 'app.js',
filename: '[name].js',
},

devtool: isProduction ?
Expand Down