Skip to content

Using breakpoint functions that return Signal (smaller, greater, etc.) causes error NG0602 #1

Closed
@alexandrutatarciuc

Description

@alexandrutatarciuc

I have a scenario where the breakpoint is dynamic and I pass it as an input to my component. Therefore, I cannot call the breakpoint functions at the root level – I have to call them within another computed signal or within effect.

private breakpoints = observeBreakpoints(breakpointsTailwind);
private worksFine = this.breakpoints.smallerOrEqual("md");

// The problem 👇
private doesNotWork = computed<boolean>(() => {
    const signal = this.breakpoints.smallerOrEqual(this.inputBreakpoint());
    return signal();
  });
public inputBreakpoint = input<"sm" | "md" | "lg" | "xl" | "2xl">("sm");

However, this causes this error
image

REPRO
Try to run the app, and check the console

I suppose the only way to solve this issue is to pass the injection context to either the breakpoint function or to the observeBreakpoints

P.S. Many thanks for this library, the usage is elegant and straightforward. I am more than happy to contribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions