Skip to content
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

Add support for async initialisation (similar to option type) #84

Merged
merged 7 commits into from
Jun 27, 2018

Conversation

pavadeli
Copy link
Contributor

@pavadeli pavadeli commented Jun 22, 2018

Closes #58, but built into the main Sherlock library. It turned out that a separate sherlock-async library has more downsides than upsides. The implementation is much simpler this way while having very limited overhead.

Note, this is effectively a rewrite of the derivables (reactors and dependency tracking are mostly untouched).

  • introduce Symbols for all important internal constructs that could otherwise result in unexpected behavior
  • introduce unresolved state and error state in all derivables (including constant and atom) that propagates to all derivations

Docs are tracked in separate issues #86 and #87.

@coveralls
Copy link

coveralls commented Jun 22, 2018

Coverage Status

Coverage decreased (-0.2%) to 99.735% when pulling 584d8a0 on option-type into 68dab27 on master.

@pavadeli pavadeli changed the title Option type Add support for async initialisation (similar to option type) Jun 24, 2018
@@ -90,4 +90,148 @@ describe('rxjs/rxjs', () => {
expect(complete).to.be.false;
});
});

describe('fromObservable', () => {
it('should be unresolved when not connected and no fallback is given', () => {

This comment was marked as resolved.

expect(d$.resolved).to.be.false;
});

it('should subscribe on observable when used to power a reactor', () => {

This comment was marked as resolved.

declare module './base-derivable' {
export interface BaseDerivable<V> {
get(): V;
getOr<T>(t: T): V;

This comment was marked as resolved.

abstract derive: Derivable<V>['derive'];
abstract pluck: Derivable<V>['pluck'];
connected = false;
_connected$?: SettableDerivable<boolean> = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In following 'documentation' PR, we need to explain this and its relation to the connected$ getter.

if (state !== unresolved) {
return state;
}
if (derivationStackDepth > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart. :-)

@njirem njirem merged commit d7bd687 into master Jun 27, 2018
@njirem njirem deleted the option-type branch June 27, 2018 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support async initialisation of Derivables (sherlock-async)
3 participants