You have more ways to handle functions in a Array. Any Function can include Into a Array. Array allowed all Types. Best way is to Use a pattern principel. Its a Use Case:
Want Array to handle manipulations of Data before Service called.
I Use Class Syntax for faster Sample:
Class Ainterceptor {
intercept(data){ // Do your Manipulation and Return Data }
}
Class Service{
constructor(interceptors: [new AInterceptor()])}
setUser(data){
interceptors.forEach(i => data = i.intercept(data)
saveUser(data)
}
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You have more ways to handle functions in a Array. Any Function can include Into a Array. Array allowed all Types. Best way is to Use a pattern principel. Its a Use Case:
Want Array to handle manipulations of Data before Service called.
I Use Class Syntax for faster Sample:
Class Ainterceptor {
intercept(data){ // Do your Manipulation and Return Data }
}
Class Service{
constructor(interceptors: [new AInterceptor()])}
setUser(data){
interceptors.forEach(i => data = i.intercept(data)
saveUser(data)
}
}