Meteor official tutorial's and Session


#1

Hi I am beginner and trying to learn meteor and was doing official tutorial and have couple of questions
in step 8 of tutorial https://www.meteor.com/try/8
Q#1

     event.target.checked

Does it give us value of check box either it is checked or not ? What exactly it is saving in Session? Can you please explain it little more?

Q#2
He used helper

  hideCompleted: function () {
return Session.get("hideCompleted");

}

Even if i do not write this helper the check box to hide completed tasks still works perfectly then why i should write this helper ?


#2

You could just find your own answers by using debugging breakpoints in e.g. Chrome DevTools by finding the source file in the “Sources” tab and clicking on a line number, then running the code and inspecting all values and executing any code there in the console.

Or by using console.log.

console.log(event.target.checked, Session.get('hideCompleted'))

EDIT: Scratch this next part of the answer. I should not look at code when not paying full attention myself. Sorry about that and thanks to @NickTheTurtle for clarifying.
That should not be the case. Maybe you didn’t save the code after removing the helper and so the app was still running with the helper in it? Or something else.
If you remove the helper, save the code, reload the whole app page in the browser, your Session will be clear of all previously set values and then the checkbox should not work any longer.

Beginner tip: Observe precisely what exactly you do or do not / did or did not do. It pays well to be very attentive. (EDIT: Yeah, and this is important not just for beginners, as we have just witnessed… :slight_smile: )


#3

Actually, if you removed the helper, it should still work. The helper only ensures that, if the Session variable somehow changes (through the console), the checkbox also changes to reflect the value.