mobxjs / mobxjs/mobx-utils

computedFn doesn't allow varying number of arguments

Open
#232 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

PR welcome!
Dominant language
TypeScript
Stars
1.2k
Forks
130
PR merge metrics
No merged PRs in 30d

Description

The computedFn function doesn't allow a varying number of arguments, between calls to the function it returns.

This is apparently already known, since the function description says:

computedFn(fn) returns a function with the very same signature. There is no limit on the amount of arguments that is accepted. However, the amount of arguments must be consistent and default arguments are not supported.

Is there a fundamental reason that you can't provide a varying number of arguments? Or has the code just not been made flexible enough yet to allow varying argument counts?

If it's the former (impossible to implement), what's the explanation for that limitation?

If it's the latter (possible to implement), then I plan to do the work of implementing it, as it's pretty important for my current use-case.

Anyway, I'm guessing it is possible, so I'm starting work on trying to implement that functionality; if it's not possible though, please let me know so I can save some time. ^_^


[potential question] Why do you need to provide a varying number of arguments?

Basically: Because that's the only way I'm able to send in an array in a way that's compatible with caching.

In more detail: I "unwrap" the array's items, and send each one in as a separate "argument" to the function. This lets the data be cached by the DeepMapEntry chain. When the function actually runs, it then reconstructs the array argument from the constituent items.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the computedFn implementation and reading its function description to understand how argument counts are handled between calls. Done means either establishing and documenting why varying argument counts cannot work, or implementing the behavior and verifying that calls with different counts remain compatible with caching.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.