-
-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add job name formatter #359
Conversation
Definitely a lot cleaner than the solution I was working on! |
Whoopsie. It appears that when no formatter is available, the whole Fix for this: const nameProp = queue.format('name', jobProps)
return {
name: (typeof nameProp === 'string') ? nameProp : jobProps.name,
} Not the cleanest solution, but keeps the UI from crashing on my end. @felixmosh can you confirm? |
Ha, you are correct :| |
The above fix would also take into account of the user accidentally passing the wrong info back. The |
If a user passes a formatter function, he "takes" responsibility on himself, no? ;] If we encounter many issues on it, I will add the check :] |
That is true; but sanitization and type safety is never a bad thing. Why else do we use tools like TypeScript? ;) The only alternative I can think would be to overload return {
name: queue.format('name', jobProps, jobProps.name)
} public format(field: FormatterField, data: any, fallbackData: any): any {
return typeof this.formatters[field] === 'function' ? this.formatters[field](data) : fallbackData || data;
} |
Fair points. I still recommend doing something other than passing the whole |
I've used your suggestion, b306477 |
Very nice. Thanks for all your hard work. I hope to help contribute more in the future. Hopefully without being a thorn in your side haha. |
closes #349