-
Notifications
You must be signed in to change notification settings - Fork 27
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
time.log() fails silently #91
Comments
I definitely agree that A pull behavior can change infinitely often and it's hard to say exactly how often What about changing the type of log(prefix?: string, sampleEvery: number = 1000): Behavior<A>; It takes second optional argument which is how many milliseconds to wait between every sampling. A default of 1000 would sample every second and by specifying the argument this can be changed. |
This would solve the problem. Very reasonable. Something about this doesn't feel right in my gut though. It feels like pull-based behaviors a really different kind of thing here. Would it be crazy to have a separate type for them? |
This issue now also tracks the fact that |
Conal says that you semantically shouldn't be able to tell when a behavior changes. I think |
The I'm not sure what statement from Conal Elliott you are referring to. But, if we're thinking of the same thing then I think what Conal meant was that you shouldn't be able to know when a behavior changes in an internal way that stems from the implementation. But, I don't think there is a problem with our Also, I made an attempt at writing down the semantics for Here |
Hm, that's a good point that Back to the original problem: specifying a sample interval feels wrong to be. I feel like its the library's job to figure out how often sampling should happen with some interval analysis. You know which parts of a behavior are pull-based, so you could start by sampling them a lot (once per milisecond) but then maybe back off it it seems to be stable for a while. Time-based behaviors change quite predictably, which should help. Would it be impractical to give people what they ask for if they do |
Not sure I follow here. What do you want to happen if you do
In the |
As long as this doesn't crash peoples' computers, I want:
If you want it to log less, divide by a multiple of 10 and round it so that it changes less often. |
To me that doesn't sound very useful. That would log 1000 messages per second which would drown everything else. The key purpose of |
We may be optimizing for different perspectives. I use I think I'd be quite confused if I did Ultimately, I'd like a uniform interface and having to specify a sample rate that's only applied for pull-based behaviors feels jagged to me. Would we do the same for |
That makes a lot of sense and I can definitely see the point here. If I understand you correctly, then from this perspective
From my perspective So, I agree that specifying a sample rate is not pretty. But, I think |
It sounds like we are mostly on the same page. My only remaining confusing is that to me it seems like our difficulty with Put another way: we could disallow Another alternative is build a So my question to you: why would |
Why is that a strange notion?
From my point of view, because that conflicts with what I think is the purpose of |
I don't normally use console.log for continuous values, because as you say, a ton of quick messages isn't that helpful. Often I whip up an on-screen debugging interface that will just show the current value at any given time. But I don't think we can do that in the console. It's only for static values. |
Yeah, the optional interval can hopefully help a bit with this.
That is a really nice solution and definitely a nicer experience. I've made attempts to close this issue:
What do you think @stevekrouse? |
Well done! Appreciate all this discussion and for getting this fixed |
Me too. I realised that I didn't answer the following:
I've thought about that as well. I don't think it would be crazy. But, I think there are good reasons for doing what we do now. First of all the difference between pull and push behaviors is an implementation detail. Conceptually or semantically the push/pull distinction doesn't exist. Hence we should try to hide that difference as much as possible. And having a The distinction that one actually could make is between behaviors that change every now and then (i.e. behaviors that change discretly many times or where the numbers of changes are countable) and behaviors that change infinitely often. This distinction makes sense conceptually—without thinking about implementation. Furthermore, calling I think what we have right now can be compared to infinite lists in Haskell. Behaviors that changes infinitely often and lists of infinite length both contain infinite information (I've heard Conal make the same analogy). There are many things that one can do with this infinite information that works fine. But, some things, like calling |
Great analysis. Thank you! |
I was reading push-pull FRP and it seems like reactive behaviors are Conal's phrase for PushBehaviors, or behaviors that change discretely. He does some clever stuff to figure out which parts of behaviors are discrete and which are continuous, but I don't think those would transfer over to a JavaScript framework. |
It should at least error if it's not going to show you anything, but I might prefer it to show me all the milliseconds.
The text was updated successfully, but these errors were encountered: