Skip to content

The project code from the Udemy course. The section on decorators

License

Notifications You must be signed in to change notification settings

monello/udemy-ts-decorators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

udemy-ts-decorators

Course by Maximilian Schwarzmüller | Understanding typeScript - 2022 Edition

This only deals with Section 9 of the course.

Code Progression notes

At the bottom of most commits you will find notes about the code changes made during that commit. I only did this for commits with code changes that progress from the previous commit, so any commits to the README.md don't have notes or navigation. I manually added page-navigation to the commits that show progress in the form of code-changes as applied by following the course.

Some commits deal with key learning points, these I will try to list below in the "Key Commits" section.

Set-up

  1. Clone the repo
  2. Install Node.js if you haven't got it installed on your system yet.
  3. In the Terminal run npm install in the root dir
  4. Run npm install -g typescript
  5. Run tsc --init
  6. Run npm start (leave it running)
  7. Open a new Terminal and run tsc -w (leave it running)

Key Commits

Comment Description Commit Shortcut
Initial Commit Listed here to be able to get to the first commit that starts the pagnation :octocat:
Basic Decorator Just a very basic decorator to illustrate the concept of decorators as simply as possible :octocat:
Factory Decorator This shows how to wrap a decorator inside a function that returns the decorator function (ie. create a decorator as a Factory function). Some of the MANY benefits of doing this is to pass in your own arguments or you can override class contructors and a lot more powerful oprions. :octocat:
Factory Decorator with Arguments This shows how you can add your custom arguments to a Factory decorator :octocat:
More useful example This shows a factory decorator with a more useful example, instead of just console.logs. This decorator adds a snippet of HTML to the page before any other code runs. (This is a VERY basic version of how AngularJS uses decorators :octocat:
Accessing a class constructor() This commit shows how powerful decorators can by accessing the class contructor() of the class being decorated from within the decorator :octocat:
Order of Execution In this commit investigates the order that decorators execute. Very interresting. :octocat:
Property Decorator Here you can see how to define a Property decorator to decorate properties of a class and what arguments to expect :octocat:
Accessor Decorator Here you can see how to define an Accesssor decorator to decorate properties of accessor methods (getters and setters) and what arguments to expect :octocat:
Method Decorator Very similar to accessor decorators. Use these to decorate class methods, again note the properties you can expect :octocat:
Parameter Decorator Shows how you can decorate the parameters/arguments of class methods. :octocat:
When are decorators executed? This commit investigates when and how many times decorators are executed :octocat:
Returning a new class from a decorator This was done in 2 parts to make it easier to see the changes step-by-step Part 1 :octocat: Part 2 :octocat:

About

The project code from the Udemy course. The section on decorators

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published