Hang on, I'm not saying flux is dead, or that redux isn't amazing.
Okay ...
Most everybody is familiar with flux by now:
User Interaction --event data-->
Action Creator --action-->
Dispatcher --payload-->
| import {Socket} from "phoenix" | |
| let socket = new Socket("/socket", { params: {} }) | |
| socket.connect() | |
| let channel = socket.channel("updates", {}) | |
| channel.join() | |
| // Reload the app if it's out of date when it joins the websocket | |
| let revision = null |
| var webpack = require('webpack') | |
| var ExtractTextPlugin = require('extract-text-webpack-plugin') | |
| var shared = require('./shared') | |
| module.exports = { | |
| devtool: 'inline-source-map', | |
| entry: [ | |
| 'webpack-dev-server/client?http://localhost:3000', | |
| 'webpack/hot/only-dev-server', |
Hang on, I'm not saying flux is dead, or that redux isn't amazing.
Okay ...
Most everybody is familiar with flux by now:
User Interaction --event data-->
Action Creator --action-->
Dispatcher --payload-->
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
| ui2/app | |
| ├── components | |
| │ ├── Header.js | |
| │ └── Main.js | |
| ├── shared | |
| │ ├── components | |
| │ │ ├── T-test.js | |
| │ │ └── T.js | |
| │ ├── lib | |
| │ │ ├── I18n.js |
| . | |
| ├── actions | |
| ├── stores | |
| ├── views | |
| │ ├── Anonymous | |
| │ │ ├── __tests__ | |
| │ │ ├── views | |
| │ │ │ ├── Home | |
| │ │ │ │ ├── __tests__ | |
| │ │ │ │ └── Handler.js |
| The MIT License (MIT) | |
| Copyright (c) 2014 Tomas Kafka | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
| class User < ActiveRecord::Base; end; | |
| class Post < ActiveRecord::Base; end; | |
| class Comment < ActiveRecord::Base; end; | |
| class AuthorSerializer < ActiveModel::Serializer | |
| attributes :id, :name :created_at, :updated_at | |
| end | |
| class PostSerializer < ActiveModel::Serializer | |
| attributes :id, :body :created_at, :updated_at |
| namespace :deploy do | |
| desc "Hot-reload God configuration for the Resque worker" | |
| task :reload_god_config do | |
| sudo "god stop resque" | |
| sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}" | |
| sudo "god start resque" | |
| end | |
| end | |
| # append to the bottom: |