Skip to content

Instantly share code, notes, and snippets.

View lucavgobbi's full-sized avatar

Luca Gobbi lucavgobbi

View GitHub Profile
@lucavgobbi
lucavgobbi / webpack.config.js
Last active October 26, 2017 03:29
Toronto .NET Meetup file 1
//https://goo.gl/wrJXHJ
const webpack = require("webpack");
module.exports = {
entry: "./src/index.tsx",
output: {
filename: "./Scripts/bundle.js"
},
devtool: "source-map",
<!DOCTYPE html>
<html>
<head>
<title>SignalR Simple Chat</title>
<style type="text/css">
.container {
background-color: #99CCFF;
border: thick solid #808080;
padding: 20px;
margin: 20px;
let _hub;
let store = createStore(
todoApp,
// applyMiddleware() tells createStore() how to handle middleware
applyMiddleware(signalRMiddleware)
)
// Make sure signalr is connected
signalRStart(store, () => {
export function signalRStart(store: any, callback: Function) {
_hub = $.connection.myHubName;
_hub.client.firstClientFunction = (p1: any) => {
store.dispatch({ type: "SERVER_CALLED_ME", a: p1 });
}
_hub.client.secondClientFunction = (p1: string, p2: string) => {
store.dispatch({ type: "SERVER_CALLED_ME_2", value: p1 + p2 });
}
export function signalRMiddleware(store: any) {
return (next: any) => (action: any) => {
if (action.signalR) {
switch (action.type) {
case ABC:
_hub.server.methodOnTheServer();
break;
default:
{
const myCurrentState = store.getState().objectWithinState;

Keybase proof

I hereby claim:

  • I am lucavgobbi on github.
  • I am lucavgobbi (https://keybase.io/lucavgobbi) on keybase.
  • I have a public key ASCdBjhCg4BpLUSEbfgk8Yuyl75uYyqg59hq40rKf0wQ5Qo

To claim this, I am signing this object:

@lucavgobbi
lucavgobbi / index.tsx
Created June 20, 2016 01:16
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import { Well } from "./components/well";
ReactDOM.render(
<div>
<Well text="Well well well..."/>
</div>,
document.getElementById("body")
);
@lucavgobbi
lucavgobbi / well.tsx
Created June 20, 2016 01:13
well.tsx
import * as React from "react";
export interface IWellProps {
text: string
}
export class Well extends React.Component<IWellProps, {}> {
render() {
return <div className="well">{this.props.text}</div>;
}
@lucavgobbi
lucavgobbi / webpack.config.js
Created June 20, 2016 01:08
webpack.config.js
module.exports = {
entry: "./Scripts/src/index.tsx",
output: {
filename: "./Scripts/dist/bundle.js",
},
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
@lucavgobbi
lucavgobbi / tsconfig.json
Created June 20, 2016 01:01
tsconfig.json for VisualStudio TypeScript React
{
"compilerOptions": {
"outDir": "./Scripts/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react"
},
"exclude": [