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

Map & Filter Callbacks #312

Closed
Jyyjy opened this issue Nov 9, 2022 · 1 comment
Closed

Map & Filter Callbacks #312

Jyyjy opened this issue Nov 9, 2022 · 1 comment

Comments

@Jyyjy
Copy link
Contributor

Jyyjy commented Nov 9, 2022

Currently you can only set one map callback and one filter callback in packageLogs.js. This is an issue because when writing custom scripts in conent.js, the filter callback is set in injectScript(). So currently a user cannot set their own filter function.

Even if the intention is to restrict content.js to a single filter callback, the one being set in injectScript() doesn't actually filter. The filter callback being set just sends the log to the background script.

Furthermore, there is not a huge difference between the map and filter callbacks. So as a solution to the filter problem above, I am working on having a single function to add callbacks to the various package log functions, which can be called multiple times.

so instead of this:
filter(foo)
map(bar)

we can do this:
addCallback(foo)
addCallback(bar)
addCallback([baz, qux])

@poorejc
Copy link
Contributor

poorejc commented Nov 24, 2022

I love this. This has actually been a bit of a pain point for me, I like the elegant solution! I can't wait to see an example! Thanks for digging in!

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

2 participants