Comments (8)
Do you have any plans to exports as a UMD module? I find the CommonJS-only style too restrictive for a library.
Perhaps you could write it in ES6 + rollup/babel for UMD exports + system-import-transformer to replace the require()
parts. Or at least (if we need to stay synchronous) test for the global exports of RxJS as well.
I would prefer to leave localForage-observable with as little dependencies as possible, but I think that it would be great to suggest users about using this library and how it can make their life's easier 👍
from any-observable.
// also @Blesh
from any-observable.
@thgreasi The user can export to any format at build-time. I don't see any point in adding that here.
I would prefer to leave localForage-observable with as little dependencies as possible
You already have a build-system for your module, so you can just bundle this module at publish time if you don't want an extra dependency.
but I think that it would be great to suggest users about using this library and how it can make their life's easier
The thing is. It only works if the libraries they depend on add it. They don't need to. So it's kind of a chicken-egg problem.
from any-observable.
And while I have you here, I just made https://github.com/sindresorhus/awesome-observables. Let me know if you have any suggestions ;)
from any-observable.
@sindresorhus So, If I get it right, by doing a require('any-observable')
, the choice of the Observable implementation used is left to the application authors.
- Is there a suggested ES6-like way to import (other than
require('any-observable')
)? - How about the users that are using the RxJS umd package? I guess that
require('rxjs/Observable').Observable
will have no effect for them. Should we also try to retrieve theRx.Observable
from the global namespace?
from any-observable.
Is there a suggested ES6-like way to import (other than require('any-observable'))?
Same as require. You do const Observable = require('any-observable');
or import Observable from 'any-observable';
in your module. Your users do the same. They can also optionally manually set the Observable lib to use with require('any-observable/register')('zen-observable')
, but it's normally auto-detected.
Should we also try to retrieve the Rx.Observable from the global namespace?
Yes, we could do that.
from any-observable.
the choice of the Observable implementation used is left to the application authors
Exactly, they just need to make sure the register
function gets called before they load up your library that uses any-observable
:
var desiredImplementation = require('rxjs/Observable').Observable;
require('any-observable/register')(desiredImplementation); // this must come before the line below
require('localforage-observable');
Is there a suggested ES6-like way to import
As @sindresorhus stated, you can just do
import Observable from 'any-observable';
ES6 imports do present a problem for some code, since imports are hoisted.
The following will not work correctly:
import Observable from 'rxjs/Observable';
import register from 'any-observable/register';
register(Observable);
import 'localforage-observable'; // this is hoisted, so it actually occurs before the call to register()
To fix that, I've proposed #2, which would provide shortcut registrations for popular libraries.
import 'any-observable/register/rxjs'; // registers rxjs in a single import, avoiding the hoisting problem
import 'localforage-observable';
I think any-observable provides a nice solution for testing as well. For example, we will be adding observable support to execa
, and while I may write my tests using a robustly featured Observable implementation like RxJs
(taking advantage of all the goodies in the extended API to make my tests as succinct as possible), consumers are free to use a lighter weight Observable implementation in their own apps.
from any-observable.
Also, it's worth pointing out this idea is stolen from any-promise
, that project is a pretty huge success (they clock nearly 20,000 daily downloads from npm).
from any-observable.
Related Issues (17)
- rxjs before zen-observable? HOT 3
- Documentation
- Optional import HOT 2
- Released version is missing files HOT 2
- Support most, xstream, Bacon, Kefir and Flyd HOT 5
- Doesn't seem to work with RxJS 6 HOT 2
- Shortcut registrations? HOT 1
- [Bug] Please move rxjs dependency from dev to prod HOT 2
- Support RxJS 6 HOT 2
- Register in browser HOT 2
- ESM HOT 7
- Just use rxjs-minimal instead of both rxjs-full and minimal HOT 1
- Browser shim
- Should work, even if it's not deduped.
- Allow for different export patterns. HOT 2
- Allow registration of the Observable constructor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from any-observable.