Skip to content

Conversation

@teogeb
Copy link
Contributor

@teogeb teogeb commented Nov 21, 2024

Improved concurrency for Mapping class. Now concurrent equal get() calls share the same promise, i.e. they evaluate the valueFactory only once.

Example

const valueFactory = async () => ...
const mapping = new Mapping(valueFactory)
await Promise.all([
    mapping.get('foo'),
    mapping.get('bar'),
    mapping.get('bar'),
    mapping.get('foo'),
    mapping.get('foo')
])

Triggers two calls to valueFactory (one for foo and another for bar). Before this PR it triggered 5 calls.

Small refactoring

  • Added readonly field annotations
  • Updated deprecated jest method call

@github-actions github-actions bot added the sdk label Nov 21, 2024
@teogeb teogeb requested review from harbu and juslesan November 21, 2024 23:08
@teogeb teogeb merged commit 2dae8b0 into main Nov 22, 2024
23 checks passed
@teogeb teogeb deleted the sdk-mapping-concurrency branch November 22, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants