Created
September 18, 2012 19:56
-
-
Save avocade/3745459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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