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.

LocalStorage Observable Error: 'Decorators are not valid here.'

See original GitHub issue

Loving the package so far! Having just a small issue with the LocalStorage decorator.

Attempting to put @LocalStorage('value') within the class (or outside of it) will cause an error.

I looked further into the issue, and saw #https://github.com/Microsoft/TypeScript/issues/8257, so it could possibly be just an issue with typescript compilation?

(feel free to close out the thread if not a valid issue)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
PillowPillowcommented, Dec 15, 2016

Question though: If I change the value through dev tools on the browser, it should detect/observe the change? Or is it only through this.storage.store, that it will detect a change?

Nop it shouldn’t detect changes, you need to call this.storage.store(...) or assign a bound variable this.anAttribute = 'hello'.

Btw, the library includes a cache system, so if you change a value in the storage during a test session, this value will not change in the app. You need to refresh the page after any direct change in the localStorage/sessionStorage to ensure that the lib takes the new value.


Edit: Since v1.4 this is not true anymore.

0reactions
donjaecommented, Oct 10, 2016

Lol, it’s working now.

I figured out my issue. I was changing values through the browser dev tools, to see if it observed the changes (it didn’t). But once I implemented some tests using your packages methods, I saw that it did observe the changes. Good to know that it can only detect changes through your methods, and was confused as to if I did something wrong on my end.

Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Decorators are not valid here" for methods inside an ... - GitHub
Error TS1206 : Decorators are not valid here on a non-top level class # ... LocalStorage Observable Error: 'Decorators are not valid here....
Read more >
ts1206 decorators are not valid here, Angular 2 - Stack Overflow
This error came to me when I used angular routing and defined routes after @NgModule decorator. We need to define routes or any...
Read more >
angular/angular - Gitter
I'm getting this error when requesting from google places api. No 'Access-Control-Allow-Origin' header is present on the requested resource.
Read more >
Implementing Persistency over localStorage - SurviveJS
It is easy to end up in a situation where localStorage contains invalid data due to changes made to the data model. This...
Read more >
Managing App State | Aurelia
The decorator will attempt to call stateChanged(newState, oldState) when no settings are passed, a function is used or an object settings is used...
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