check out my latest app: Icon Preview
and my latest blog post
Support any Observable library and polyfill
License: MIT License
check out my latest app: Icon Preview
and my latest blog post
Similar to any-promise
: https://github.com/kevinbeaty/any-promise/blob/master/register-shim.js
any-promise uses a global to ensure it works, even when it's not deduped.
The string only option does not fit RxJs.
You can't do:
require('rxjs/Observable');
You need to do:
require('rxjs/Observable').Observable;
I think our default lookup strategy should be something like this:
function load(name) {
var loaded = require(name);
return loaded.Observable || loaded.default || loaded;
}
Is it possible that the auto detect feature doesn't work for RxJS 6? Might have to pull in @benlesh here because I'm not sure what all the changes are in this new version.
So we try to load in rxjs/Observable
right here. But it looks like that doesn't exist anymore and you need to import directly from rxjs
instead.
So we can easily fix this by adding rxjs
to the libs
list as the last element in order to support RxJS 6. But before I do a PR, I need to be sure that my findings are correct.
We should write better documentation than just pointing to any-promise
(though we can probably steal a good bit from there).
One important thing the any-promise
documentation does is to offer a separate "Library Usage" section that discusses how Library authors should behave:
any-observable
support prominently.Hi,
rxjs is required by any-observable during runtime. It is in devDependencies but should be in dependencies. Could you please make the change? This is causing issues when this library is installed by pnpm. We have a workaround to patch your package.json but ideally we would like to remove it.
Thank you in advanced,
-Rafael
Similar to any-promise
require('any-observable/register')('rxjs', {Observable: require('rxjs/Observable').Observable});
Open to an ESM PR, for native ESM and/or Rollup?
I like that you can pick your desired registration. That's awesome. I never stopped to look at any-promise
before. I dig it.
What about providing a list of shortcut registrations so you can do this:
ava --require=any-observable/register/zen
ava --require=any-observable/register/rxjs-minimal
ava --require=any-observable/register/rxjs-all
Keep them in a registration
subfolder so they don't clutter up the main code base, and you can be pretty liberal about accepting PR's with registration shortcuts as new implementations become available.
I tried to use any-observable
but received the error
Error: Cannot find module './register'
Dived into the code and it looks like the version that is being released on npm
has the following files
property specified.
"files": [
"index.js"
]
Is it possible to do a new released in between to fix that?
@thgreasi @zerkalica What do you think about a solution like this to support multiple Observable implementations? Would you use this in your Observable-using modules?
See this comment.
RxJs uses an interesting loader mechanism that allows users to specify exactly which Observable methods are implemented. This allows them to pursue a robust API, and users don't necessarily have to pay the price with larger browserified packages. (I think you can accomplish similar with bluebird, but it requires a build step - rxjs automates feature selection via require/import statements - it's pretty cool). More details here
Anyways. I think we should probably just select the minimal install when auto-resolving. Then users can patch to get the features they want, but we aren't necessarily loading the entirety of rxjs.
And drop support for RxJS 5.
IssueHunt has been backed by the following sponsors. Become a sponsor
An import that won't throw:
var Observable = require('any-observable/optional');
// => null if there is no implementation
Parcel, babel, browserify and webpack seem to support optional require:
let Observable
try { Observable = require('zen-observable') } catch (e) {}
Is there any sense to enable register-shim
to detect available observable libs as well?
It's got way more methods, lots more features. It seems to be the bluebird
of observables (not sure on performance).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.