Skip to content

Instantly share code, notes, and snippets.

View yreynhout's full-sized avatar
👔
ceci n'est pas une cravate

Yves Reynhout yreynhout

👔
ceci n'est pas une cravate
View GitHub Profile
@yreynhout
yreynhout / gist:593356
Created September 23, 2010 08:51
Rx testable chaining and streaming
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ConsoleApplication4 {
public class Input {
public string DataYouGotFromSomeDataSource { get; set; }
}
@yreynhout
yreynhout / gist:656386
Created October 31, 2010 10:09
Guard members
public class Order : Aggregate {
public Order Place(Customer customer, ...) {
customer.GuardPlaceOrder();
//...
}
}
public class Customer Aggregate {
private bool _hasMoreThanFiveOutstandingInvoices;
@yreynhout
yreynhout / Viewmodels1.html
Created August 4, 2012 09:27
Viewmodels - Sample 1
<html>
<head>
<link rel="stylesheet" href="http://current.bootstrapcdn.com/bootstrap-v204/css/bootstrap-combined.min.css"></link>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.1.0.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.21/jquery-ui.js"></script>
<script type="text/javascript" src="http://current.bootstrapcdn.com/bootstrap-v204/js/bootstrap.min.js"></script>
<script type="text/javascript">
var PageViewModel = function() {
if (!this instanceof PageViewModel) {
@yreynhout
yreynhout / Viewmodels.js
Created August 4, 2012 10:32
Viewmodels - Building blocks
var TextInput = function (validationOptions) {
if (!this instanceof TextInput) {
return new TextInput(validationOptions);
}
validationOptions = validationOptions || {
rules: {},
messages: {}
};
@yreynhout
yreynhout / Viewmodels.js
Created August 4, 2012 11:04
Viewmodels - Building blocks
var Trigger = function () {
if (!this instanceof Trigger) {
return new Trigger();
}
var self = PausableSubscriberExtension(
DisposableExtension(
FocusExtension(
EnableExtension(
VisibleExtension(
@yreynhout
yreynhout / Viewmodels.js
Created August 4, 2012 11:32
Viewmodels - Sample 2
var ThingInputViewModel=function() {
if(!this instanceof ThingInputViewModel) {
return new ThingInputViewModel();
}
var states={ none: 0, adding: 1,modifying: 2 };
var self=this,
statemachine=new SimpleStatemachine({ initialState: states.none }),
baseData,
@yreynhout
yreynhout / Viewmodels.js
Created August 4, 2012 11:36
Viewmodels - Sample 3
var ThingInputViewModel=function() {
if(!this instanceof ThingInputViewModel) {
return new ThingInputViewModel();
}
var self=this;
self.Name=new TextInput({
rules: {
required: true,
@yreynhout
yreynhout / Viewmodels.js
Created August 5, 2012 09:45
Viewmodels - Sample 4
var PageViewModel = function() {
if(!this instanceof PageViewModel) {
return new PageViewModel();
}
var self=this;
self.Navigation=new NavigationViewModel();
self.List=new ListViewModel();
self.Detail= new ThingDetailViewModel();
@yreynhout
yreynhout / Viewmodels.js
Created August 5, 2012 11:28
Viewmodels - Sample 5
var ThingDetailViewModel = function() {
if (!this instanceof ThingDetailViewModel) {
return new ThingDetailViewModel();
}
var self = this,
states = { none: 0, adding: 1, modifying: 2},
statemachine = new SimpleStatemachine(states.none),
baseData = null,
buildCommand;
@yreynhout
yreynhout / ViewmodelBinding.html
Created August 5, 2012 16:03
Viewmodels - Sample 6
<div class="setup-table">
<table>
<thead>
<tr>
<th colspan="2">Name</th>
</tr>
</thead>
<tbody data-bind="foreach: List.Items">
<tr data-bind="css : { selected : IsSelected }">
<td data-bind="click: Select.Command, text: Name.Value">