Coder Social home page Coder Social logo

hold's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hold's Issues

holdAdd needs to use scheduler.asap, rather than emitting an event directly

From the architecture wiki:

"A producer source must never produce an event in the same call stack as its run method is called. It must begin producing items asynchronously."

The holdAdd() method is currently violating this policy, resulting in errors in certain edge cases.
https://github.com/mostjs/hold/blob/master/src/index.js#L36

To elaborate on the error, in some cases when a single source exists at two places in a composed stream (potentially via most-proxy), it is possible for a sink constructor call to be on the stack, call its upstream source.run(), and then to end up on the stack a second time for an upstream run call. If the upstream run call then tries to bypass the scheduler and emit an event synchronously, without allowing the run stack to finish first, then because event and dispose can both be called in the same stack, the sink whose constructor is still on the stack can have dispose called before its disposable property has finished being assigned, resulting in the error:

TypeError: Cannot read property 'dispose' of undefined

Strange Behavior with Stream of Numbers

So, I came across a strange behavior while messing around with @most/hold. For the example, consider the following function which produces a infinite stream of numbers (starting with 0) according to a given time period:

const interval = period => filter(x => x !== -1, scan((x, y) => x + y, -1, constant(1, skip(1, periodic(period)))));

Well, now, consider the following code:

//let testHold = hold(interval(2000));
let testHold = multicast(interval(2000));

runEffects(tap(console.log, take(3, testHold)), newDefaultScheduler());

setTimeout(()=>{
    runEffects(tap(console.log, take(11, testHold)), newDefaultScheduler());
}, 4500);

With multicast, the code works as expected, printing: 0, 1, 2, 2, 3, 4, 5, ...
But, with hold, it acts strangely, printing: 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6
I personally was expecting something more like 0, 1, 1, 2, 2, 3, 4, 5, ....
In other words, the second run should access the second emission (last from first run at time 4000 milliseconds), print one more number (2) together with the first run (the last number taken from the first run), and keep printing the reaming sequence.

Additionally, the program keeps hanging after the last two 6

Update peerDependency of most to 0.17.1

Overview

Update the peer dependency on most to the latest version 0.17.1

Motivation

So other packages that depend on this library can update to 0.17.1 of most

Documentation precision

"Deliver the most recently seen event to each new observer the instant it begins observing"

This sentence could make someone think the observer will observe a value synchronously when it doesn't ? (setTimeout(fn, 0) so could be anywhere between 1 and 10ms)

Problem with Types

Hey, guys!

I installed @most/hold last version (3.0.0) and for some reason the type definition file seems to be out-of-date. In this way, it raises the following error while building my code:

node_modules/@most/hold/type-definitions/hold.d.ts:1:59 - error TS2307: Cannot find module 'most'.

1 import {Stream, Source, Sink, Scheduler, Disposable} from "most";

I've checked the commits, and the above import was in fact present in hold.d.ts until the commit 15ee95c

Migration to TypeScript

Hi, @briancavalier!

While working on #34 I ran into various issues related to Flow. Flow has poor tooling and IDE support (with almost no hints in IDE), I was able to run typechecking only with npm run test:flow.
I think migrating to TypeScript which has a way better IDE support and tooling would provide the best developer experience.

If you approve I would open a PR with migration to the most strict typescript configuration and with transparent changes of build steps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.