Chapters
19 Chapters
|
1:38:39
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.2.0
Subscribe to download the code!Compatible PHP versions: ^7.2.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
02.
Arrow Functions
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
This tutorial uses Symfony 3. But, since this is a JavaScript tutorial, all the concepts work fine in newer versions of Symfony.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.2.0",
"symfony/symfony": "3.2.*", // v3.2.14
"twig/twig": "2.10.*", // v2.10.0
"doctrine/orm": "^2.5", // v2.7.1
"doctrine/doctrine-bundle": "^1.6", // 1.10.3
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"symfony/swiftmailer-bundle": "^2.3", // v2.4.2
"symfony/monolog-bundle": "^2.8", // v2.12.1
"symfony/polyfill-apcu": "^1.0", // v1.3.0
"sensio/distribution-bundle": "^5.0", // v5.0.22
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.19
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"friendsofsymfony/user-bundle": "~2.0@dev", // dev-master
"doctrine/doctrine-fixtures-bundle": "~2.3", // v2.4.1
"doctrine/doctrine-migrations-bundle": "^1.2", // v1.2.1
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"friendsofsymfony/jsrouting-bundle": "^1.6" // 1.6.0
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.2
"symfony/phpunit-bridge": "^3.0" // v3.2.2
}
}
8 Comments
Hello, I have : RepLogApp.js:166 Uncaught ReferenceError: Routing is not defined at RepLogApp.js:166
I Don't know what to do.
Hey Developper,
Did you download the course code and started from start/ directory? Did you follow the instructions in the starts/README.md file? If so, please, stop everything running and start the instructions from the README file again, please.
Cheers!
Not Routing, Swal
Hey @Developper!
Ah sorry you're having trouble! So, to be clear, your error is about how "Swal" is not defined? Are you getting this error after downloading the code from this page? If so, are you using the start/ or finish/ directory?
Let us know and we'll do our best to help :).
Cheers!
Javascript error in the source code when you are trying to submit a form without filling it :
RepLogApp.js:104 Uncaught (in promise) SyntaxError: Illegal continue statement: no surrounding iteration statement
To avoid it, just change the keyword "continue" in the _mapErrorsToForm method of RepLogApp.js . to "return". It will do the trick.
Hey tilotiti!
Good find! Thanks for letting us know! We made a recent change, but actually made it in the wrong spot - return is correct (as you mentioned) - we'll change that back. Later in the tutorial when we refactor this to a for loop, THEN continue is the correct choice. Sorry about that - but thanks for the comment!
Cheers!
Hi. In the example console.log(this, self) area the same but at the top of the script you still calling them method using .bind(this). Is not that the reason?
Hey micayael!
Ah, good question! At the top of the script, we use the .bind(this) on
handleRepLogDelete,handleRowClickandhandleNewFormSubmit. But, we do not call it onloadRepLogs, which is what we're calling here.And actually, to be fully clear, that doesn't matter at all! When we call
.then()on.ajax(), that callback is not bound to this. And so, unless you use an arrow function,thiswill be different in that callback. You could also accomplish this with bind - it would look like this:In this case - I'm passing a normal (non-arrow) function to .then(). So, it should normally have a different "this". But, because I call .bind(this) ON that callback function, it will retain the proper "this". Overall, this shows that - yes - the arrow function and .bind() solve the same problem. The arrow function is just a little bit nicer :).
I hope that clarifies! Cheers!
"Houston: no signs of life"
Start the conversation!