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 1 commit
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
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.

26 changes: 26 additions & 0 deletions src/element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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;
function main( sources ) {
const sandbox = Sandbox( sources );
const sinks = {
DOM: sandbox.DOM,
store: Observable.merge( sandbox.data ).scan(merge, { route: key, inputs: undefined }),
Copy link
Author

@xtianjohns xtianjohns Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this static .merge() anymore. I'll fix this.

};
return sinks;
}

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

customElements.define( 'rx-marbles', SandboxElement );
3 changes: 2 additions & 1 deletion test-custom-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<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="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