get_it icon indicating copy to clipboard operation
get_it copied to clipboard

registerFactoryParam should receive a Record

Open feinstein opened this issue 1 year ago • 7 comments

registerFactoryParam and registerFactoryParamAsync have a very limited API. We can only pass 2 parameters and their names aren't descritive enough of their purposes.

With Records added to dart 3, I think we can make a braking change to these methods where they receive a Record instead. This way we can define what are our parameters with a Record, since a Record signature is pretty much the same a Function's parameter signature.

feinstein avatar May 29 '23 15:05 feinstein

That's a real Interesting idea, will look into it

Thomas Am 29. Mai 2023, 17:36 +0200 schrieb Michel Feinstein @.***>:

registerFactoryParam and registerFactoryParamAsync have a very limited API. We can only pass 2 parameters and their names aren't descritive enough of their purposes. With Records added to dart 3, I think we can make a braking change to these methods where they receive a Record instead. This way we can define what are our parameters with a Record, since a Record signature is pretty much a Function signature. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

escamoteur avatar May 29 '23 15:05 escamoteur

Besides removing one parameter, there would be no need to change anything, as a gerenic type can alredy be a recoed, or do I miss something here?

escamoteur avatar May 30 '23 07:05 escamoteur

I confess I still didn't play with Records, but as far as I understand yes, you only need to remove 1 parameter, so the function will only accept one generic parameter, then make it positional and not named, and then in the docs and readme explain how to use it with records.

feinstein avatar May 30 '23 14:05 feinstein

unfortunately optional positional parameters can't be mixed with named ones yet. therefore we would need to keep it a named one because we always have to offer the 'instanceName` parameter.

escamoteur avatar May 30 '23 14:05 escamoteur

Ah, OK, I didn't remember the parameters tbh, that's fine, I would just rename it to something else than param.

feinstein avatar May 30 '23 15:05 feinstein

I am open for any proposals what better name for a value that is passed as parameter Am 30. Mai 2023, 17:23 +0200 schrieb Michel Feinstein @.***>:

Ah, OK, I didn't remember the parameters tbh, that's fine, I would just rename it to something else than param. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

escamoteur avatar May 30 '23 15:05 escamoteur

args... just kidding, I can't come up with a better name, I didn't realize we can't remove it.

feinstein avatar May 30 '23 15:05 feinstein