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
@connect((store) => ({ | |
moviesWithGosling: store.movies.filter(movie => movie.get('cast').includes(1512)) | |
})) |
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
@connect((store, ownProps) => ({ | |
category: getCategoryById(ownProps.categoryId, store.sports.get('categories')), | |
matches: filterMatchesByCategoryId(ownProps.categoryId, ownProps.matches) | |
})) |
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
import React from 'react' | |
const fetchResources = (mapResourcesToProps) => (ComposedComponent) => { | |
return class extends React.Component { | |
static displayName = `Fetch(${ComposedComponent.displayName || ComposedComponent.name})` | |
render() { | |
return <ComposedComponent {...this.props} /> | |
} | |
} |
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 fetchResources = (mapResourcesToProps) => (ComposedComponent) => { | |
return class extends React.Component { | |
static displayName = `Fetch(${ComposedComponent.displayName || ComposedComponent.name})` | |
state = {} | |
componentDidMount() { | |
const mapResult = mapResourcesToProps(this.props) | |
const resourceProps = Object.keys(mapResult) | |
const resourcePromises = Object.values(mapResult) |
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 styleable = (ParentComponent) => class extends ParentComponent { | |
static displayName = `Styleable(${ParentComponent.displayName || ParentComponent.name})` | |
} |
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 styleable = (ParentComponent) => class extends ParentComponent { | |
static displayName = `Styleable(${ParentComponent.displayName || ParentComponent.name})` | |
render() { | |
const originalElement = super.render() | |
const className = `${originalElement.props.className} ${this.props.className}` | |
const style = {...originalElement.props.style, ...this.props.style} | |
const newProps = {...originalElement.props, className, style} | |
return React.cloneElement(originalElement, newProps) |
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
@styleable | |
class Example extends React.Component { | |
render() { | |
return ( | |
<div className="test" style={{fontSize: 30}}> | |
Test | |
</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
// Separate url validation logic from Replies.sayInvalidLinkedInUrl side effect. | |
// This way you can reuse this function in other methods | |
const getUrlFromEvent = (event) => Maybe.of(event) | |
.filter(x => event.message.nlp.entities.url) | |
.filter(x => event.message.nlp.entities.url[0].domain !== 'linkedin.com') | |
.chain(x => Maybe.fromNullable(extract(event.message.nlp.entities.url))) | |
consume.onUserState('preferences/linkedin/url', ({ event, userId }) => getUrlFromEvent(event) | |
.caseOf({ | |
Just: (url) => Promise.all([User.updatePreferences(userId, {linkedIn: url[0]}), Dispatch.linkedInUrlReceived({ userId })]), |
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
interface ADTKind<T> { | |
kind: T | |
} | |
type ADT1<Name, T> = (...args: [T]) => ADTContainer1<Name, T> | |
type ADT2<Name, T, T2> = (...args: [T, T2]) => ADTContainer2<Name, T, T2> | |
type ADT3<Name, T, T2, T3> = (...args: [T, T2, T3]) => ADTContainer3<Name, T, T2, T3> | |
class ADTContainer1<Name, T> implements ADTKind<Name> { | |
kind: Name = null as any as Name |
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
headerToUsername :: Text -> Maybe Text | |
headerToUsername authHeader = do | |
JWT.stringOrURIToText <$> (JWT.sub =<< JWT.claims <$> JWT.decode authHeader) | |
headerToUsernameDo :: Text -> Maybe Text | |
headerToUsernameDo authHeader = do | |
unverifiedJwt <- JWT.decode authHeader | |
subject <- JWT.sub $ JWT.claims unverifiedJwt | |
return $ JWT.stringOrURIToText subject |
OlderNewer