Skip to content

Instantly share code, notes, and snippets.

@jaredtmartin
jaredtmartin / app.jsx
Created September 29, 2015 23:07
Simple example of React Transitions in Meteor
// Just create a new Meteor app, add the packages below, delete the css, html, and js files and copy this file in.
// Packages to add:
// meteor add react
// meteor add velocityjs:velocityjs
// Click on the text and see it fly!
ReactTransitionGroup = React.addons.TransitionGroup;
Title = React.createClass({
componentWillEnter(done){
console.log('Will Enter');
@jaredtmartin
jaredtmartin / gist:8309126
Created January 7, 2014 23:53
Grouping Breaks Reactivity
// collections/assignments.js
Deps.autorun(function(){
Assignments.grouped = {};
var raw_list = Assignments.find().fetch();
for (var i = raw_list.length - 1; i >= 0; i--) {
if (Assignments.grouped[raw_list[i].date] == undefined) {Assignments.grouped[raw_list[i].date]={}};
if (Assignments.grouped[raw_list[i].date][raw_list[i].meetingId] == undefined) {Assignments.grouped[raw_list[i].date][raw_list[i].meetingId]=[]};
Assignments.grouped[raw_list[i].date][raw_list[i].meetingId].push(raw_list[i]);
};
});
@jaredtmartin
jaredtmartin / gist:8309085
Created January 7, 2014 23:49
Grouping Broke Reactivity
// collections/assignments.js
Assignments.group_assignments = function(){
console.log('Grouping Assignments');
var grouped = {};
var raw_list = Assignments.find().fetch();
for (var i = raw_list.length - 1; i >= 0; i--) {
if (grouped[raw_list[i].date] == undefined) {grouped[raw_list[i].date]={}};
if (grouped[raw_list[i].date][raw_list[i].meetingId] == undefined) {grouped[raw_list[i].date][raw_list[i].meetingId]=[]};
grouped[raw_list[i].date][raw_list[i].meetingId].push(raw_list[i]);
};
@jaredtmartin
jaredtmartin / ifchanged
Last active December 31, 2015 00:59
How can I make a block helper for meteor. I need something similar to django's ifchanged template tag.
{{#each meetings}}
{{#ifchanged date}}
</ul>
<div class="date">{{date}}</div>
<ul class="list-group">
{{/ifchanged}}
<li>{{title}}</li>
{{/each}}
Given this:[{title:"Foo",date:"Today"}, {title:"Bar",date:"Today"}, {title:"Foo",date:"Tomorrow"}, {title:"Bar",date:"Tomorrow"}]