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

Accept subscriptions #4

Open
JesusTheHun opened this issue Nov 30, 2023 · 0 comments
Open

Accept subscriptions #4

JesusTheHun opened this issue Nov 30, 2023 · 0 comments

Comments

@JesusTheHun
Copy link

This lib is great for other libs because it is minimal, there is nothing to learn.

I maintain a few packages, some with IO, like database IO.
I use @open-draft/logger and I would like the consumer of my lib to be able to receive its logs, like database query.
But you don't want to handle every logging logic, there are great libs out there for that.

If one could just subscribe(fn), it would allow consumers to plugin in their own solution, without us, maintainers having to manage anything.

// lib.ts
const logger = new Logger('someLib');
export const onSomeLibLog = logger.subscribe;

// app.ts
import { onSomeLibLog } from 'someLib';

onSomeLibLog(log => {
  appLogSolution.write(log);
})

I'm willing to submit a PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant