A function to use with xstream#compose to filter repeated events
Example
stream
.compose(distinct((a, b) => a.id === b.id)
.map(uniqueValue => { //... })
### Keybase proof | |
I hereby claim: | |
* I am nickydonna on github. | |
* I am nickydonna (https://keybase.io/nickydonna) on keybase. | |
* I have a public key ASDVLuuLrKCEGq9uk1NHRsK1r9uSxdx_WNJuQmUBv5TFOAo | |
To claim this, I am signing this object: |
const hasMark = window.performance && !!window.performance.mark; | |
const Performance = () => { | |
const defaultMark = {}; | |
const getTiming = () => { | |
const timing = performance && performance.timing ? performance.timing.toJSON() : {}; | |
const defaultTiming = {ipsyPageStart: __PAGE_START__, ipsyPageEnd: __PAGE_END__}; | |
return {...timing, ...defaultTiming}; |
import React, {Component, Fragment} from 'react'; | |
import { Modal, ModalBody, ModalHeader, ModalFooter, Button } from 'reactstrap'; | |
/* eslint react/jsx-filename-extension: 0 */ | |
const ErrorModal = ({error}) => ( | |
<Modal isOpen={showError} toggle={toggleError}> | |
<ModalHeader toggle={toggleError}>Felicitaciones</ModalHeader> | |
<ModalBody> | |
<div className="col-md-6 offset-md-3"> | |
{error} |
// option one - using Promise.all - I like this the most | |
asyncAuth() | |
.then(user => { | |
return Promise.all([user, asyncFetch(user)]) | |
}) | |
.then(([user, data]) => { | |
// ... | |
}); | |
// option two - nesting |
export const delayMiddleware = (delay) => (req, res, next) => { | |
setTimeout(next, delay) | |
}); |
// @flow | |
import React from 'react'; | |
import styled from 'styled-components'; | |
import { Segment } from 'semantic-ui-react'; | |
import { parsePadding } from '../utils/styledHelpers'; | |
import type { Component as ComponentType } from 'styled-components'; | |
type FlexItemProps = { | |
flex?: string|number, |
// flow | |
import type { MiddlewareAPI, Dispatch } from 'redux'; | |
import { Socket } from 'phoenix'; | |
const url = 'ws://localhost:4000/socket'; | |
const usefullAction = [ | |
'CHANNEL_PUSH', | |
'CHANNEL_DISCONNECT', | |
'EVENT_CONNECT', | |
'EVENT_DISCONNECT', |
const isArray = Array.isArray; | |
const reducer = (acc, ele) => { | |
const elements = isArray(ele) ? flatten(ele) : ele; | |
return acc.concat(elements); | |
}; | |
const reduce = (arr) => arr.reduce(reducer, []); | |
const flatten = arr => isArray(arr) ? reduce(arr) : arr; | |
module.exports = flatten; |
/* @flow */ | |
import BrowserHistory from 'react-history/BrowserHistory' | |
import {Push, Replace} from 'react-history' | |
import React, {Component} from 'react' | |
import {StaticRouter} from 'react-router' | |
type RouterProps = { | |
onChange: (action: string, location: Object) => void, | |
pathname: string, | |
navigation?: 'PUSH' | 'REPLACE', |