3

I'm trying to figure out how to use rx.js with a dog-simple example, but can't figure out what reference or file I'm missing that means it isn't working.

<!DOCTYPE html>
<html>
<head>
    <title>Empty</title>
    <script src="/Scripts/rx.js"></script>
</head>
<body>
    <script>
        var thing = Rx.Observable.fromEvent(document, 'keydown');
    </script>
</body>
</html>

That's literally it. The script line correctly loads a local copy of rx.js 2.4.1 freshly downloaded from nuget.

I'm getting the error Rx.Observable.fromEvent is not a function, so I'm assuming that there is a missing reference.

It might just be the time of night, but I'm struggling to see what I'm doing wrong. Any help?

mistakenot
  • 554
  • 3
  • 14
  • Please create a snippet of code that reproduces your issue. How do you know that the script is loaded properly? – artur grzesiak Mar 13 '15 at 07:04
  • On loading this HTML page, Firebug console reports on load the mentioned error. When I view source and click on the link for the rx.js script, it takes me through and loads up the required source file. – mistakenot Mar 13 '15 at 12:10
  • So, you are sure that `Rx` is present on `window`? Anyway please reproduce it somewhere (so-snippet/fiddle/plnkr/codepen/etc). – artur grzesiak Mar 13 '15 at 12:32
  • Thanks for your help, I've found the missing files. – mistakenot Mar 13 '15 at 12:52

1 Answers1

5

Resolved by downloading and using additional Rx files rx.async.js and rx.binding.js like so:

<!DOCTYPE html>
<html>
<head>
    <title>Empty</title>
    <script src="/Scripts/rx.js"></script>
    <script src="/Scripts/rx.async.js"></script>
    <script src="/Scripts/rx.binding.js"></script>
</head>
<body>
    <script>
        var thing = Rx.Observable.fromEvent(document, 'keydown');
    </script>
</body>
</html>
mistakenot
  • 554
  • 3
  • 14