Skip to content

Selector constructor is contre-intuitive and doesn't parse "keyexpr?params" format #190

@milyin

Description

@milyin

The Selector is a pair of Keyexpr + Parameters which can be constructed from a string of format "a/b/c?d=e;f=g" where "a/b/c" is keyexpr and "d=e;f=g" is parameters.

The typescript doesn't support multiple constructors so the prototype of Selector constructor is

  constructor(selector: IntoSelector, parameters?: IntoParameters) {

From this definition it's not clear that the parameters are actually ignored if the selector have Selector type.

Also the implementation of this constructor doesn't try to parse keyexpr?params strings. The IntoSelector type makes user expect that it should. There is such functionality in other bindings (TryFrom<&'a str> in Rust, parse_selector in C++),

The proposal is:

  • make type of first parameter IntoKeyexpr | IntoSelector. This is excessive but makes intention more clear
  • if string of format "keyexpr?params" is passed, parse it
  • if first parameter contains parameter and second parameter exists, throw exception
  • explain this behavior in doc above

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions