Skip to content

Instantly share code, notes, and snippets.

@avocade
Created September 18, 2012 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avocade/3745459 to your computer and use it in GitHub Desktop.
Save avocade/3745459 to your computer and use it in GitHub Desktop.
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