This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const colors = require('css-color-list')() | |
| // Returns an observable that emits a color every 10ms. | |
| // Stops when we've gone through every color. | |
| const getColorsObservable = () => | |
| Rx.Observable.interval(10) | |
| .map(i => colors[i]) | |
| .takeWhile(color => color != null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const defaultState = { search: '', results: [] } | |
| const store = createStore((state = defaultState, action) => { | |
| switch (action.type) { | |
| case 'SET_SEARCH': | |
| return { ...state, search: action.search, results: [] } | |
| case 'ADD_RESULTS': | |
| return { ...state, results: state.results.concat(action.results) } | |
| default: | |
| return state | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const App = connect(state => state, dispatch => ({ | |
| setSearch: e => { | |
| dispatch({ type: 'SET_SEARCH', search: e.target.value }) | |
| } | |
| }))(({ search, results, setSearch }) => ( | |
| <div> | |
| <input value={search} onChange={setSearch} /> | |
| {results.map(result => ( | |
| <div key={result}>{result}</div> | |
| ))} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rx.Observable.from(store) | |
| .map(state => state.search) | |
| .distinctUntilChanged() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rx.Observable.from(store) | |
| .map(state => state.search) | |
| .distinctUntilChanged() | |
| .switchMap(search => ( | |
| getColorsObservable() | |
| .filter(color => color.includes(search)) | |
| )) | |
| .subscribe(result => { | |
| store.dispatch({ type: 'ADD_RESULT', result }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (root, wrapper) { | |
| if (typeof define == "function" && define.amd) define([], function () { | |
| return wrapper; | |
| });else if (typeof module == "object" && module.exports) module.exports = wrapper;else (root.nbind = root.nbind || {}).init = wrapper; | |
| })(this, function (Module, cb) { | |
| if (typeof Module == "function") { | |
| cb = Module;Module = {}; | |
| }Module.onRuntimeInitialized = function (init, cb) { | |
| return function () { | |
| if (init) init.apply(this, arguments);try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <title>Ripple Carousel</title> | |
| <style> | |
| input { | |
| box-sizing: border-box; | |
| width: 200px; | |
| } | |
| .options { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <title>Dropdown</title> | |
| <style> | |
| input { | |
| box-sizing: border-box; | |
| width: 200px; | |
| } | |
| .options { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const createDataFetcher = (url) => { | |
| let result = null | |
| let promise = null | |
| return () => { | |
| if (result != null) { | |
| return result; | |
| } | |
| if (promise === null) { |