Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Type-safe flux example #81

Merged
merged 8 commits into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 201 additions & 0 deletions react-with-type-safe-flux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
dist/

# Visual Studo 2015 cache/options directory
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# JUnit test results
test-results

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding addin-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
*.[Cc]ache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
bower_components/
typings/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt
22 changes: 22 additions & 0 deletions react-with-type-safe-flux/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 John Reilly

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:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

49 changes: 49 additions & 0 deletions react-with-type-safe-flux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Type-Safe Flux Example

Based on [ES6 + TypeScript + Babel + React + Karma: The Secret Recipe](../es6-babel-react-flux-karma), see more in corresponding [blog post](https://sameroom.io/blog/type-safe-flux-architecture-using-typescript/).

## Getting started

You'll need [node / npm](https://nodejs.org/) installed. To get up and running just enter:

```
npm install
npm run tsd install
npm run serve
```

This will:

1. Download the npm packages you need
2. Download the typings from DefinitelyTyped that you need.
3. Compile the code and serve it up at [http://localhost:8080](http://localhost:8080)

Now you need dev tools. There's a world of choice out there; there's [Atom](https://atom.io/), there's [VS Code](https://www.visualstudio.com/en-us/products/code-vs.aspx), there's [Sublime](http://www.sublimetext.com/). There's even something called [Visual Studio](http://www.visualstudio.com). It's all your choice really.

For myself I've been using Atom combined with the mighty [atom-typescript package](https://atom.io/packages/atom-typescript). I advise you to give it a go. You won't look back.

## I want to have an ASP.Net project and use Visual Studio + IIS Express to serve this instead

If you drop this code into an empty Visual Studio ASP.Net project should should be good to go. You'll need this section in your `web.config` to ensure Visual Studio serves from the `dist` directory:

```
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Map all requests to 'dist' directory" stopProcessing="true">
<match url="^(.*)$" />
<action type="Rewrite" url="/dist/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
```

And rather than running `npm run serve` you'll want to use `npm run watch`. (This builds / watches your code / runs tests etc but does **not** spin up a web server.)

Finally you'll want to set the following TypeScript options for your project

- ECMAScript Version: ECMAScript 6
- JSX compilation in TSX files: Preserve
73 changes: 73 additions & 0 deletions react-with-type-safe-flux/gulp/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"root": true,
"env": {
"commonjs": true,
},
"rules": {
"camelcase": 2,
"comma-spacing": 1,
"consistent-return": 2,
"curly": [ 2, "all" ],
"dot-notation": [
2,
{ "allowKeywords": true }
],
"eol-last": 2,
"eqeqeq": 2,
"keyword-spacing": 2,
"new-cap": 2,
"new-parens": 2,
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-parens": [ 2, "functions" ],
"no-implied-eval": 2,
"no-iterator": 2,
"no-labels": 2,
"no-label-var": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 1,
"no-undef-init": 2,
"no-unused-expressions": 2,
"no-use-before-define": [ 2, "nofunc" ],
"no-with": 2,
"quotes": [ 1, "single" ],
"semi": 2,
"semi-spacing": [
2,
{
"before": false,
"after": true
}
],
"space-infix-ops": 2,
"space-unary-ops": [
2,
{
"words": true,
"nonwords": false
}
],
"strict": [ 2, "global" ],
"yoda": [ 2, "never" ]
}
}
29 changes: 29 additions & 0 deletions react-with-type-safe-flux/gulp/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

var del = require('del');
var gutil = require('gulp-util');
var fs = require('fs');

function run(done) {
fs.stat('./dist', function(err){
if (err) {
// Never existed
done();
}
else {
del(['./dist'], { force: true })
.then(function(paths) {
gutil.log('Deleted files/folders:\n', paths.join('\n'));
done();
})
.catch(function(error) {
gutil.log('Problem deleting:\n', error);
done();
});
}
});
}

module.exports = {
run: function(done) { return run(done); }
};
Loading