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.

es module observable error "could not be converted"

See original GitHub issue

hi!

i’m trying to set up a modern build-free app using mobx, htm, preact, and native es modules

i get an error when i try to use observable

esmodule (codepen)

  • import {observable} from "https://unpkg.com/mobx@5.9.0/lib/mobx.es6.js"
    observable("anything")
    

error

  • Uncaught Error: [mobx] The provided value could not be converted into an
    observable. If you want just create an observable reference to the object 
    use 'observable.box(value)'
    
      invariant$$1 @ mobx.es6.js:16
      fail$$1 @ mobx.es6.js:11
      createObservable @ mobx.es6.js:402
      (anonymous) @ pen.js:4
    

i don’t know what’s wrong


I have a:

  • Issue:
    • Provide error messages including stacktrace
      • Uncaught Error: [mobx] The provided value could not be converted into an
        observable. If you want just create an observable reference to the object 
        use 'observable.box(value)'
        
          invariant$$1 @ mobx.es6.js:16
          fail$$1 @ mobx.es6.js:11
          createObservable @ mobx.es6.js:402
          (anonymous) @ pen.js:4
        
    • Provide a minimal sample reproduction. Create a reproduction based on this sandbox
      • its only two lines but i have this codepen
    • Did you check this issue wasn’t filed before?
    • Elaborate on your issue. What behavior did you expect?
      • i expected observable not to throw an error for primitives like strings or numbers
    • State the versions of MobX and relevant libraries. Which browser / node / … version
      • mobx@5.9.0, chrome@71.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
fi3eworkcommented, Mar 20, 2019

@chase-moskal The target of observable should be an object. If you wanna observe a primitive value, please use observable.box, see details here.

1reaction
Maaartinuscommented, Mar 18, 2019

@chase-moskal I’m a beginner here, but isn’t this what the documentation says?

The string "anything" is immutable and therefore

  • it can’t be made observable
  • there’s nothing to observe as it can’t change

A primitive-valued field is a different story.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in importing Observable from 'rxjs/Observable' in angular 4
But in another question from Stack, i read that way will increase the page load (Best way to import Observable from rxjs).
Read more >
Export final code? - Community Help - The Observable Forum
You can convert your Observable notebook to a standard ES module (by hand for now), but since ES imports aren't reactive and don't...
Read more >
HTTP Example with Observables • Angular - codecraft.tv
So the map operator isn't converting a string to SearchItem[] it's converting a string to Observable<SearchItem[]> . So the subscribe function is receiving ......
Read more >
Error codes - CKEditor 5 Documentation
Error codes. CKEditor 5 Framework logs errors and warnings to the console. The following list contains more detailed descriptions of those issues.
Read more >
toPromise - Learn RxJS
Convert observable to promise. ... ⚠ toPromise is not a pipable operator, as it does not return an observable.
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