├── .babelrc
├── .gitignore
├── .npmignore
├── README.md
├── example
├── index.html
├── package.json
├── src
│ ├── Item.ts
│ ├── List.ts
│ └── index.ts
├── tsconfig.json
└── typings.json
├── package.json
├── src
└── index.ts
└── tsconfig.json
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "es2015"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Editor-specific
2 | .idea
3 | *.sublime-project
4 | *.sublime-workspace
5 | .settings
6 |
7 | # Installed libs
8 | node_modules
9 |
10 | # Misc
11 | npm-debug.log
12 | .DS_Store
13 | ignore/
14 | dist/
15 | lib/
16 | typings/
17 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Editor-specific
2 | .idea
3 | *.sublime-project
4 | *.sublime-workspace
5 | .settings
6 |
7 | # Installed libs
8 | node_modules
9 |
10 | # Misc
11 | npm-debug.log
12 | .DS_Store
13 | ignore/
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cycle.js `customElementify`
2 |
3 | ##### Experimental
4 |
5 | Helper function that takes a Cycle.js component (`(sources: Sources) => Sinks`) and returns a JavaScript class that can be registered as a Web Component custom element with `document.registerElement`:
6 |
7 | ```js
8 | import customElementify from 'cycle-custom-elementify';
9 |
10 | function main(sources) {
11 | // ...
12 | }
13 |
14 | const customElementClass = customElementify(main);
15 | document.registerElement('my-web-component', { prototype: customElementClass });
16 | ```
17 |
18 | ```html
19 |
20 | ```
21 |
22 | ## Installation
23 |
24 | ```
25 | npm install cycle-custom-elementify
26 | ```
27 |
28 | #### Required!
29 |
30 | Your target browser must support [Custom Elements v0](http://webcomponents.org/polyfills/custom-elements/) or install the polyfill for other browsers:
31 |
32 | - `npm install webcomponents.js`
33 | - Cycle DOM v12.2.4
34 | - [This Snabbdom Pull Request](https://github.com/paldepind/snabbdom/pull/159) needs to be applied before you can use this library
35 | - Include `` in your page
36 |
37 | This library is experimental and so far **only** supports Cycle.js apps written with xstream. You can only `customElementify` a function that expects xstream sources and sinks.
38 |
39 | ## Usage
40 |
41 | Your Cycle.js component function can expect sources to have `DOM` and `props`:
42 |
43 | ```typescript
44 | // TypeScript signature:
45 | type Sources = {
46 | DOM: DOMSource,
47 | props: Stream