Comments (9)
Another approach would be to swap seed
and fn
arguments so it will be .diff(fn, seed)
instead of .diff(seed, fn)
. Then it will become clear which argument is omitted:
diff(a)
— seed omitteddiff(null, a)
— fn omitteddiff()
— both
But it's a breaking change ...
from kefir.
Another approach would be to swap seed and fn arguments so it will be .diff(fn, seed) instead of .diff(seed, fn).
These sounds like proper way. Same order as in Array.prototype.reduce
.
BTW how about diff(seed, fn)
, diff(seed)
, diff()
and diffByFunction(fn)
(or simply diffBy(fn)
)?
from kefir.
Yeah, I am also thinking of doing swapping.
But not sure about diffByFunction
/ diffBy
, diff(null, a)
is good enough.
from kefir.
Kefir uses semver so nothing stops you to make breaking changes in next major version.
Also something like diff(_.noop, seed)
looks much better then diff(null, seed)
I think. But there is another issue when you really need to return undefined
value in diff function.
from kefir.
Now I think diff(null, seed)
is ok. As it in Node.js callback error conventions and in some other libraries.
Just noticed, documentation says that
If no fn function provided, function(a, b) {return [a, b]} will be used as default.
Why not just identity function of new value?
Also I believe that swapped order (i.e. function (next, prev) { /* ... */}
) is more traditional. Diffs algorithms in all major libraries and frameworks use that order. In this way you can just omit old value in callback function if you don't need it.
from kefir.
Now I think diff(null, seed) is ok
Yes, we can't use _.noop
, because it will result in observable always emitting undefined
(which _.noop
always return).
Why not just identity function of new value?
If function(a, b) {return b}
was used, then a.diff(seed)
would be equivalent of just a
.
from kefir.
Yes, we can't use _.noop, because it will result in observable always emitting undefined (which _.noop always return).
But I mean diff(_.noop, seed)
not diff(_.noop(), seed)
. _.noop
itself is not undefined but function so it'll be used as diff function returning null.
If function(a, b) {return b} was used, then a.diff(seed) would be equivalent of just a.
That makes sense.
from kefir.
so it'll be used as diff function returning null
yep, and that null
will be emitted from result observable. That what I am trying to say)
from kefir.
oh I just hasn't realized that we are speaking about same things sorry
from kefir.
Related Issues (20)
- KefirJS and WebSockets HOT 4
- Only `sampledBy` is past tense
- Current state policies HOT 2
- Idea: Usable as AsycInterator
- Proposal to add `fromProperty` static function HOT 15
- Static Land interop `Observable` definition is wrong HOT 5
- Shouldn't a property only emit on "new values"? Proposing `onChange()` HOT 1
- Missing type for `unplug`
- Maintain TypeScript types? HOT 4
- Stop bundling `symbol-observable`
- TypeError: this._emitValue is not a function HOT 1
- Make subscription available inside callback HOT 8
- A big "Thank You" to Kefir developers HOT 1
- How to import Kefir within Rollup library HOT 3
- groupBy function HOT 8
- flatMapConcat should work when a spawned observable ends synchronously on activation
- Add documentation to "Kefir.pool" as "Rx.Subject equivalent" HOT 2
- Synchronous emit in flush method of debounce produces incorrect result HOT 8
- Is it possible to not activate a staled observable when reactivating flatMapLatest? HOT 8
- Russian docs translate
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 kefir.