Skip to content

Instantly share code, notes, and snippets.

@bomatson
bomatson / react.md
Created August 25, 2014 18:57
A Prosperous Alternative to Marionette

Alternative to Marionette

Marionette does an incredible job of managing complex view structure, but it feels like a stronger tool than necessary given the requirements of the Borrower Funnel. Using a combination of React and Backbone.router would reduce the amount of code, but still give us the ability to manage validation and views. Below are some notes about this alternative

Pros to ReactJS

Keeping developers away from manipulating the DOM directly. It wraps each HTML element in a React.DOM object, making it a bit easier to work with (we found it to be very digestable). It also allows for very reusable, and easily testable, code.

Chapter 11 Thoughts

Feature simulation - why rebuild the feature as a fallback, wouldn’t that take up a lot of dev time and be a little error prone?

Object detection seems like the best way to handle browser inconsistencies - if the object has this property, use it

function bindEvent(elem, type, handle) {
 if (elem.addEventListener) {
require 'sinatra'
require 'httparty'
response = HTTParty.get('http://worldcup.sfg.io/matches/')
array = response.parsed_response
@matches = array
# @home_country= ['home_team']['country']
# @away_country= ['away_team']['country']
# ^^^^ we won't want to define our instance variables here, they should be within the 'get' block below:
require 'sinatra'
require 'httparty'
response = HTTParty.get('http://worldcup.sfg.io/matches')
PARSED_DATA = response.parsed_response
GAMES = []
COUNTRIES = [] # I tried adding .uniq and .uniq! to the end of every reference to this [COUNTRIES] array and could not get it to remove the duplicates???
require 'sinatra'
apps = [ "nachos", "guacamole", "bloomin\' onion", "bread sticks", "garlic knots" ]
entrees = [ "chicken parm\'", "lamb kabob", "veggie fajitas"]
desserts = ["chocolate lava cake", "fruit & cheese plate", "salted caramel pudding"]
drinks = ["water", "hot water"]
# if you wanted to make the image urls work, you would need to restructure the data a little bit.
# we want to get in the habit of each potential course being its own object, with properties you can access
# an array of hashes is perfect for our current use case:
<h1>
Welcome to Restaurant GA!
</h1>
<h2>
Menu
</h2>
<form action="/order" method="post">
<h3>
Appetizers
require 'sinatra'
MENU = {
# what happens if your appetizers have more than just an image and name? how about if there's a phone number?
# we want to get in the habit of each appetizer being its own object, with properties you can access
# an array of hashes is perfect for our current use case:
# appetizers = [
# {'name' => 'fries', 'image_url' => 'http://frenzyofnoise.net/wp-content/uploads/2014/05/French-fries-deliciouse.jpg' }, ...
# ]
# Mashable Bookmarks
# ==================
# Using http://mashable.com/stories.json and sinatra, show a webpage listing all the articles with images next to them.
# Bonus
# -----
# * Filter by category
# * Filter by author
require 'sinatra'
require 'httparty'
# nice work ! very clean route here :)
get '/' do
# since you're not using @resp in your view,
# you can make this a regular ruby variable:
# Class 07 Homework
# 7.3.2014
# By Josh Esguia
# ASSIGNMENT
# Using http://mashable.com/stories.json and sinatra, show
# a webpage listing all the articles with images next to them.