I am using below metoer method to create new user:
Meteor.methods({ "users.add": function(newUser) { let cResult = Accounts.createUser({ username: newUser.username, email: newUser.email, password: newUser.password, profile: { first_name: newUser.first_name, last_name: newUser.last_name, clinic: newUser.clinic } }); for (let index in newUser.roles) { Roles.addUsersToRoles(cResult, newUser.roles[index].label); } return true; }, "users.addRole": function(userId, newRole) { Roles.addUsersToRoles(userId, newRole); return true; } });
However, getting race condition in the default rendering, if i refersh I am getting the correct data. My github repo is https://github.com/tejaser/clinic.git
Finally resolved by putting a simple check on the react render method for undefined which allowed it render new data with null and then update it when the information came from the roles subscribe method.
I am using below metoer method to create new user:
Meteor.methods({ "users.add": function(newUser) { let cResult = Accounts.createUser({ username: newUser.username, email: newUser.email, password: newUser.password, profile: { first_name: newUser.first_name, last_name: newUser.last_name, clinic: newUser.clinic } }); for (let index in newUser.roles) { Roles.addUsersToRoles(cResult, newUser.roles[index].label); } return true; }, "users.addRole": function(userId, newRole) { Roles.addUsersToRoles(userId, newRole); return true; } });
However, getting race condition in the default rendering, if i refersh I am getting the correct data. My github repo is https://github.com/tejaser/clinic.git