Closed itaym2 closed 7 years ago
Props is definitely better, What about more js approach:
rootDispatcher.withProps({firstName: user.firstName, lastName:user.LastName})
Sounds good to me. Also we should consider changing the term filter, since it doesn't filter anything. More like middelwares.
I think filters and middlewares are pretty equivalent in web, as seen in asp.net mvc filters, iis isapi filters, ruby on rails filters, play framework filters. However, both concepts (middlewares and filters) are commonly used in servers, in clients usually the concept is interceptors, but it feels weird. If we look at filters as low-level building blocks for building enhancers, we can provide a friendlier (and maybe mutation free) api for adding just-before-dispatch dynamic properties (or meta).
dispatcher.withDynamicProps({eventTime: (props)=> new Date().getTime())
While filters abstraction can be useful, we can keep it for more advanced usages. (for example, PII filter)
I think the name "ExtraData" is confusing. Why is this data is extra? What data is not extra? I think changing the name to EventProp or Props or something similar and updating the dsl accordingly will make the meaning clearer: