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

import signature (in practice) incompatible with Sink #67

Open
RubenVerborgh opened this issue Mar 28, 2022 · 1 comment
Open

import signature (in practice) incompatible with Sink #67

RubenVerborgh opened this issue Mar 28, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@RubenVerborgh
Copy link
Member

The Dataset signature is

Promise<Dataset> import (Stream stream);

In contrast, the Sink signature is

EventEmitter import (Stream stream);

which makes it hard for objects to implement both cleanly.

In theory, we could return Promise<Dataset> & EventEmitter or even be fancy and do Promise<Dataset & EventEmitter> & EventEmitter for full .then compatibility, but this gets messy.

Any chance we could either rename this method or change its return type?

@RubenVerborgh RubenVerborgh added the bug Something isn't working label Mar 28, 2022
@bergos
Copy link
Member

bergos commented Mar 29, 2022

It would be the same for the match method. I don't think it makes sense to prefix or postfix the methods to distinguish them. The stream and dataset interfaces are for different use cases. The import method of the Dataset is the only method that consumes a Stream and creates a bridge between both worlds. As the Stream is just consumed, using the Dataset interface doesn't require deeper knowledge about the Stream interface. The name import is the best match for this use case. For the rare case where you want to have both interfaces, it's probably better to use different objects for each interface. Like this:

const dataset = factory.dataset()
const store = new DatasetStore(dataset) 

// store.dataset implements the Dataset interface
await store.dataset.import(quadStream)

// store implements the Store interface
store.match().on('data', quad => console.log(quad))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants