Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 widget injection in connect command #238
Add support for widget injection in connect command #238
Changes from 6 commits
999c6ec
927fac7
ddc45b2
b933cfa
a517d70
6d0fad0
73035a6
b3ebb18
e66e8a3
b314119
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it would be clearer if there was a function whose purpose is to convert labels to an array of
Record<string, string>
. this function's responsibility is more strictly defined IMO, with concepts like key case not included.then have a separate function which maps the record objects to a
ScriptInjection
explicitly:Bonus - you can use Zod to verify and convert the schema including coercing to boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, it'd be parseScriptInjection = recordParser(def)
// recordParser = (def) => (Record<string,string >)=> T
// where def can be something declarative as Zod)
But I think it's a bit pre-mature to extract it and Zod is a bit tricky since it translate 'false' to true which might be correct in js, but we are in the context of configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably worth logging the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we talking about injectAll? The args are there for inferring the signature type, they are prefixed with
_
as they are not in useThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can return a function instead of an object with a single key. or even simpler IMO - remove the nested func and have a single function with combined args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created it initially as a single function, the reason for creating the nested function is for currying the service (id, params) from the injection context (model, filter), otherwise it doesn't provide much value compared to using addScript (which is used externally) directly.
The reason for returning an object and not a single function was for better communicating the action.