Skip to content

Instantly share code, notes, and snippets.

@avocade avocade/gist:3745459
Created Sep 18, 2012

Embed
What would you like to do?
Users = new Meteor.Collection 'users'
currentUser = ->
Users.findOne Session.get 'user_id'
if Meteor.is_client
Meteor.startup = ->
Meteor.autosubscribe = ->
Meteor.subscribe 'users'
Template.users_to_interrupt.users = ->
usersint = Session.get 'users_to_interrupt'
if usersint
Users.find { username: { $in: (usersint || []) } }
Template.add_user.events
'click button.add': ->
username = $('#add_username').val()
$('#add_username').val('')
console.log "got username '#{username}' in add user textfield"
array = Session.get('users_to_interrupt') || [] # if we do Session.get here it screws up notifying on Session.set later! must get the value otherwise somehow
# array = [] # just adding an empty array and pushing username to it works, and updates "users" reactively
array.push(username)
Session.set 'users_to_interrupt', array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.