remix-run / history

Manage session history with JavaScript
MIT License
8.3k stars 960 forks source link

suggest to make 'createEvents' type friendley #955

Open Yuddomack opened 2 years ago

Yuddomack commented 2 years ago

I was trying to create a custom event for experiment (like this #949) but did some mistakes because the type was not clear little.

I didn't want to someother make same mistake, Help them see for themselves what they are doing.

so I added a type specification to help with type inference.

It make improve type inference

before (any) after (inferred)
image image
image image

+ Additionally

multiple parameter passing is possible by this

call(...arg) {
  handlers.forEach((fn) => fn && fn(...arg));
}
before after
image image

if you don't think need multi parameter, can change like this

Thank you

Please consider to this pull request! and Thank you for providing a good ecosystem!