I no longer mantain this list. There are lots of other very comprehensive JavaScript link lists out there. Please see those, instead (Google "awesome JavaScript" for a start).
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.
A quick rant.
- PouchDB is slow, because it doesn't use bare-metal IndexedDB
OK, first off I want to point out the CanIUse table for IndexedDB. Go ahead, look at it. I'll wait.
| angular.module('swag', []) | |
| .controller('MainController', function(MyApi) { | |
| $scope.submit = function(data) { | |
| MyApi.get(data).then(function(data) { | |
| // redirect or some action here | |
| alert(data); | |
| }) | |
| .catch(function(err) { | |
| // ui logic belogs here | |
| alert(err); |
module.view() is a deliberately half-baked attempt at implementing a web components pattern in angular.
It began as a convenience wrapper on module.directive() to avoid specifying the templateUrl in a context where the templateUrl is derivable from the name of the view.
It also allows views to be included via expression (see example below), which is useful for routing, modals, and other dynamic view inclusion.
| import {Component as _Component, Template as _Template} from 'angular2/src/core/annotations/annotations'; | |
| function makeDecorator(annotationClass) { | |
| return (options) => { | |
| return (klass) => { | |
| klass.annotations = klass.annotations || []; | |
| klass.annotations.push(new annotationClass(options)); | |
| return klass; | |
| }; | |
| }; |
| /* | |
| The MIT License (MIT) | |
| Copyright (c) 2014 | |
| 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 |
| import {bootstrap, Component, Decorator, View, If, For, EventEmitter} from 'angular2/angular2'; | |
| import {FormBuilder, Validators, FormDirectives, ControlGroup} from 'angular2/forms'; | |
| @Component({ | |
| selector: 'app', | |
| injectables: [FormBuilder] | |
| }) | |
| @View({ | |
| template: ` | |
| <div class="container" [control-group]="myForm"> |
| // <script src="angular.min.js"></script> | |
| (function(name, factory) { | |
| // our basic IO module system that stores every module on modules with the "file" namespace | |
| // please use something like browserify rather than rolling your own like this | |
| window.modules = window.modules || {}; | |
| window.require = window.require || function require(name) { return window.modules[name] || window[name]; }; | |
| var exports = {}; factory(exports, window.require); | |
| window.modules[name] = exports; | |
| }('TodoService', function(exports, require) { |