-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stateless? #1
Comments
Well spotted and you probably have not. (And also, having const TakeFirstIn = I.inherit(
function TakeFirstIn(info, sources, n) {
Ineffectual.call(this, info, sources)
this.n = n
},
Ineffectual,
{
next(value) {
propagateNext(value, this)
const n = this.n
if (0 === n || 0 === (this.n = n - 1)) enqueueComplete(this)
}
}
)
const TakeFirstEf = effectualFrom1(TakeFirstIn)
export const takeFirst = I.curry((n, sources) => {
const info = analyzeSources(sources)
return hasVarying(info)
? new TakeFirstEf(info, sources, Math.max(0, n))
: valueFrom(info, sources)
}) export const effectualFrom1 = Class1 =>
I.inherit(
function EffectualFrom1(info, sources, arg1) {
Effectual.call(this, info, sources)
this.arg1 = arg1
},
Effectual,
{
fork(info, sources) {
return new Class1(info, sources, this.arg1)
}
}
) It is been nearly a year since I last worked on this. IIRC, the draft code I have on my machine introduced some significant changes to the implementation (basically making more intelligent analysis of the source observable template separating what is known statically vs what is known dynamically etc) and is not yet working properly (which is probably why I didn't push it to the repo). |
Speaking of stateful combinators, then actually one of the reasons why |
Let me try to clarify a bit more. As said in the const a_plus_b = E.lift((a, b) => a + b)(a, b) Of course, (Strictly speaking it introduces a bit of state in the form of a cache of the latest value of the property. However, that cache is to be updated from the sources IOW, the idea is to support a style of programming where state is primarily kept outside of program components so that those program components themselves then become stateless (and become easier to reason about, compose in various ways, and to refactor). Contrast the canonical Calmm export const Counter = ({value}) => (
<div>
<button onClick={U.doModify(value, R.dec)}>-</button>
{value}
<button onClick={U.doModify(value, R.inc)}>+</button>
</div>
) and e.g. the Now, obviously, for a library like this to make any sense, there must be ways to introduce stateful properties (otherwise there would be only constants and there would be no point to have this library). One way to introduce those in this library would be by creating first class "atoms" that explicitly store state and that can be explicitly mutated using actions like This differs from traditional event stream libraries where state is to be primarily introduced via combinators like So, I would argue that introducing the notion of stateful atoms is an essential ingredient of actually enabling one to create stateless components, because the other approach of using event streams, Now, back to On the other hand, there are cases where it does seem preferable to be able to introduce some temporary (local) state for various reasons. Being able to execute side-effects is one of those. That is what |
You're saying that this library is about stateless properties. Yet
takeN
, for example, is clearly stateful. Have I understood your definition of statelessness wrong?The text was updated successfully, but these errors were encountered: