1. Execute run_app.sh
./run_app.sh
This script do:
- Check if folder
app/node_modules
exists, and runnpm install
if not - Move the
.ts
filedecorator.debounce-throttle.ts
into folderapp/
so that Angular is able to find it - Run a tmp server on port 4200. Check it on
http://localhost:4200/
- Change (or add)
@debounce_or_throttle(x, x, x)
in your own*.component.ts
, e.g.,app.component.html
in this demo
- Following refs help a lot when writing this decorator script
- Intro and examples for debouncing and throttling
- Angular window resize event (@HostListener)
- Angular Debounce decorator example
- Throttle implementation
- These Q&As on stackoverflow help on fixing the bug:
this = undefined
- Fixed on
#L23
&#L55
- By adding
this
as the first arg (because arrow function not allow doing so, the name_dummy
is given)
- By adding
- This project is licensed under the MIT License
Feel free to modify it to your own version as needed- Remember to remove all
console.log()
before really using the decorator (at lines#L31,33,41,45,47,58,60,65,67
) - Since this project is more for a demo rather than a production
- Remember to remove all
- I am the beginner of Angular, so feel free contact me if having any comments :D