question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: Angular 9 doesn't work correctly with NGXS decorators with UMD

See original GitHub issue

🐞 bug report

Affected Package

@angular/compiler

Is this a regression?

Yes

Description

https://stackblitz.com/edit/angular-9-ngxs?file=src/app/store/todo/todo.state.ts

@Persistence([
  {
      path: 'todos',
      existingEngine: localStorage
  }
])
@StateRepository()
@State<TodoStateModel>({
  name: 'todos',
  defaults: {
    todos: [],
    loaded: false,
    selectedTodo: null
  }
})
@Injectable()
export class TodoState
  extends NgxsDataRepository<TodoStateModel> {

  @Selector()
  public static todos(state: TodoStateModel) {
    return state.todos;
  }

  constructor(private readonly api: TodoApiService) {
    super()
  }

}

image

NGXS validates decorators through a handle. But now this does not work with Angular 9. However, if you build the application locally on the machine, everything works. Doesn’t work only on stackblitz, is that because it uses CommonJS?

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-9-ngxs?file=src/app/store/todo/todo.state.ts

🔥 Exception or Error


Error in /turbo_modules/@ngxs/store@3.6.2/__ivy_ngcc__/bundles/ngxs-store.umd.js (4626:23)
Selectors only work on methods

🌍 Your Environment

Angular Version:

Angular 9.1.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, May 21, 2020

It appears from talking to their team that this is actually a small bug in StackBlitz. apai4 is going to put a fix together! I am closing this here as it is not an issue with the Angular Framework.

0reactions
angular-automatic-lock-bot[bot]commented, Jun 21, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NGXS doesn't work when update to Angular 9 with Ivy enabled
You aren't using the action in the action stream ( _actions$ ) correctly. Try changing ofActionSuccessful(this.addItem(plan)),. to
Read more >
ngxs - Bountysource
Ngxs router state is out of sync with Angular router state when route resolvers are running. Minimal Reproduction. I have created a stackblitz...
Read more >
Error Handling - NGXS
Handling errors after dispatching an action ... If an unhandled exception is thrown inside an action, the error will be propagated to the...
Read more >
Open Source Used In MSX Managed Device Service Pack 4.0.0
This document contains licenses and notices for open source software used in this product.
Read more >
ngRx/Store and 5 silly mistakes - ITNEXT
If you work with Angular you definitely know about the most popular ... can spend hours on debugging if something doesn't work as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found