Skip to content

Instantly share code, notes, and snippets.

View Abazhenov's full-sized avatar

Alexei Bazhenov Abazhenov

View GitHub Profile
[
{
table: 'message',
query: { outbound: false }
},
{
table: 'organization',
query: { type: 'customer' }
}
]
[
{
table: 'message',
query: { outbound: false }
}
]
RelevanceDAG.defineCascadeFor('user', async function() {
return [
await this.getOrganization(),
...(await this.getActiveLoads())
];
})
RelevanceDAG.defineCascadeFor('phone_call', function() {
return this.getParticipants();
})
ALTER TABLE load ADD COLUMN user_id INTEGER;
ALTER TABLE load
ADD CONSTRAINT user_id_constraint
FOREIGN KEY (user_id)
REFERENCES human(id);
import React from 'react'
import { mapDispatchToProps, mapStateToProps } from '../myFancyDecorators'
@mapStateToProps((state) => ({
users: state.users
}))
@mapDispatchToProps((dispatch, ownProps) => ({
getUser(id) {
dispatch(ownProps.getUser(id))
}
const mapDispatchToProps = (dispatch, ownProps) => ({
getUser(id) {
dispatch(ownProps.getUser(id))
}
})
class MyFancyComponent extends React.Component {
// react things
}
@Abazhenov
Abazhenov / react-redux-decorators.js
Created December 28, 2017 17:44
decorators for react-redux
import { connect } from 'react-redux'
const mapStateToProps = (mapStateToProps, options) => {
return connect(mapStateToProps, {});
}
const mapDispatchToProps = (mapDispatchToProps, options) => {
const mapStateToProps = () => ({});
return connect(mapStateToProps, mapDispatchToProps);
}
@Abazhenov
Abazhenov / ConnectedComponent.js
Last active June 15, 2018 10:06
connect decorator example
import React from 'react'
import { connect } from 'react-redux'
const mapStateToProps = (state) => {
return { users: state.users };
}
const mapDispatchToProps = (dispatch, ownProps) {
return {
getUser(id) {
@Abazhenov
Abazhenov / Component.js
Created December 28, 2017 17:09
connect without decorator
import React from 'react'
import { connect } from 'react-redux'
class MyFancyComponent extends React.Component {
// react things in here
}
const mapStateToProps = (state) => {
return { users: state.users };
}