Skip to content

Instantly share code, notes, and snippets.

View sajithdilshan's full-sized avatar

Sajith Edirisinghe sajithdilshan

View GitHub Profile
import dispatcher from "../Dispatcher";
export const COLOR_APP_ACTIONS = {
CHANGE_COLOR: 'colorAppActions.ChangeColor'
};
export function changeColor(colorName) {
dispatcher.dispatch({
type: COLOR_APP_ACTIONS.CHANGE_COLOR,
value: colorName
import React from "react";
import * as ColorAppActions from "../actions/ColorAppActions";
export default class ButtonComponent extends React.Component {
onButtonClick = (colorName) => {
ColorAppActions.changeColor(colorName)
};
render() {
import dispatcher from "../Dispatcher";
import {EventEmitter} from "events";
import * as ColorAppActions from "../actions/ColorAppActions";
class ColorAppStore extends EventEmitter {
constructor() {
super();
this.activeColor = "lightgrey";
}
import React from "react";
import ColorAppStore from "../stores/ColorAppStore";
export default class ColorComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
color: ColorAppStore.getActiveColor()
}