Skip to content

Instantly share code, notes, and snippets.

@robertfw
robertfw / StoreWatchMixin.js
Created September 18, 2014 20:13
Modified Fluxxor.StoreWatchMixin to allow providing filters to conditionally trigger state update based on "change" event payload
// These changes alter the StoreWatchMixin to allow specifying filters on the
// change event, allowing components to inspect the payload before deciding
// whether to trigger.
//
// To add a filter, simply provide a function after the store name, i.e.
// mixins: [StoreWatchMixin('filtered_store', payload_filter)
//
// You may still specify multiple stores.
//
// The filter function should expect to receive a single argument, the payload
<html>
<head>
<title>client</title>
<script src="http://localhost:8888/socket.io/socket.io.js"></script>
<script type="text/javascript">
var socket = new io.Socket('localhost');
socket.connect();
socket.on('connect', function()
{
console.log('connected');