Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Log an error/warning for undefined values in RxState operators #639

Copy link
Copy link
Open
@mrkpks

Description

@mrkpks
Issue body actions

Improve the DX by logging an error/warning for unexpected @rx-angular/state operators behavior when passing undefined values

As a developer I'd like to see a warning or an error when I'm passing undefined value to a RxState#select or RxState#selectSlice operators. I stumbled into these issues myself and also heard about them from my colleagues when they started using RxState library on their projects.

What passing an undefined value actually causes is that the part of the template bound to e.g. *rxLet directive won't render at all. This is quite easy to spot if you are only using single prop binding but if you are using the ViewModel approach with lots of properties inside of a selectSlice operator, this can be difficult to discover if it is not a known issue for the developer.

Solution

Throw an error when undefined value is passed to the operator and show additional message to the developer that he/she should

  • either make sure that the source of the property that is state connected to never emits undefined values
  • or initialize state with default values (e.g. null)
    Note: the latter is a good practice, which should probably be also documented in the RxState guidelines.

Alternatives Considered

Showing a warning should be also sufficient (but possibly less sufficient for less experienced developers) - should be discussed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.