Open cmarcao opened 2 years ago
@EricSmekens and @LeaVerou - any thoughts on this? I know when we first started moving into a plugin system, this was discussed, but then dropped to reduce complexity/scope. I feel like this could be useful in some cases and could be re-done similar to what this commit removed?
Any proposal for additional complexity should be justified through use cases. What are the use cases for having multiple parsers with different configurations and how common are they?
@LeaVerou I would like to use jsep in a library with a custom binary operator but I cannot because of the singleton nature of it might lead to transient, hard to locate bugs
I think what @joeflateau said sums it up for me.
If writing an application, then the singleton nature most likely isnt an issue.
But if writing a library, it could be an issue if some other component of the application also uses jsep.
I was considering using this for an application, where I would want to be able to parse boolean expressions and number expressions separately under different rules. While I could manage with this singleton, it would require swapping out the acceptable operators and things each time I want to parse an expression, which is rather wasteful.
related to #28
Hi guys.
There is any reason to have a singleton parser? There is no chance to have more than one jsep with different configuration running in the same app at client side?
Thank you,
Carlos Marcão