Skip to content

Instantly share code, notes, and snippets.

View RichardBray's full-sized avatar
😎
Fix bug , drink milkshake, code feature, repeat.

Richard Oliver Bray RichardBray

😎
Fix bug , drink milkshake, code feature, repeat.
View GitHub Profile
@RichardBray
RichardBray / App.tsx
Created January 10, 2018 13:04
first bit of content for app.tsx
import * as React from "react";
export class App extends React.Component<any, any> {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
@RichardBray
RichardBray / index.tsx
Created January 10, 2018 13:15
Index with App component
import * as React from "react";
import * as ReactDOM from "react-dom";
import { App } from "./components/App";
const ROOT = document.querySelector(".container");
ReactDOM.render(<App name="Jamala" />, ROOT);
@RichardBray
RichardBray / webpack.config.js
Last active January 10, 2018 13:28
resolve and devtool
devtool: "source-map",
resolve: {
extensions: [".js", ".ts", ".tsx"]
}
@RichardBray
RichardBray / style.scss
Created January 10, 2018 13:42
some simple code for style.scss
$background-grey: #f3f3f3;
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.3rem;
background-color: $background-grey;
}
@RichardBray
RichardBray / webpack.config.js
Created January 10, 2018 13:44
Styles rule to module
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: "css-loader",
options: {
minimize: true
}
},

A Beginner's Guide to Ngrx/store

As someone who is fairly new to the world of Redux and to a certain extent Angular (not AngularJS), the thought of having to implement Redux to our app was very daunting. Not because it wasn't the right thing to do, our initial app was built quite quickly without much knowledge of Angular and in doing so it wasn't very testable, so Redux would help with that situation, the main difficulty was the learning curve.

Reducers; actions, states, the store, this vernacular was familiar to someone who had experience with Redux but not me, and the whole process is quite verbose, I mean–why would you split your code which was originally in one file, the component into multiple, the reducer, action and state? There are however, a lot of companies who use and find a lot of benefits form it, so I decided to do a deep dive into how and why it works and documented my find

from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop
class HelloHandler(RequestHandler):
def get(self):
self.write({'message': 'hello world'})
def make_app():
urls = [("/", HelloHandler)]
return Application(urls)
from tornado.web import Application, RequestHandler
# application creats app, requesthandler, deals with HTTP requests
from tornado.ioloop import IOLoop
# input output loop used to run async server
from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop
items = []
class TodoItems(RequestHandler):
def get(self):
self.write({'items': items})
from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop
import json
items = []
class TodoItems(RequestHandler):
def get(self):
self.write({'items': items})