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

Actor.useState support for any object #2814

Open
MatousMarik opened this issue Jan 16, 2025 · 0 comments
Open

Actor.useState support for any object #2814

MatousMarik opened this issue Jan 16, 2025 · 0 comments
Labels
feature Issues that represent new features or improvements to existing features. t-tooling Issues with this label are in the ownership of the tooling team.
Milestone

Comments

@MatousMarik
Copy link

MatousMarik commented Jan 16, 2025

Which package is the feature request for? If unsure which one to select, leave blank

None

Feature

I would love to use any object as a state (e.g., Set), but the function only supports simple objects that are serializable by JSON.stringify.

Motivation

I write actors, and sometimes, I have to implement everything myself by using Actor.setValue since Actor.useState is unusable in such cases.

Ideal solution or implementation, and any additional constraints

I would add an option to add a custom serialization function for the useState. Either as a type of the state e.g.:

interface ISerializable {
  toSerializable(): object | string | number | boolean | null;
}

Or as a parameter e.g. as part of UseStateOptions that are documented as follows:

options: UseStateOptions
An optional object parameter where a custom keyValueStoreName and config can be passed in.

Or another optional parameter called customSerializationFunction or something like that.

Alternative solutions or implementations

No response

Other context

Slack thread: https://apify.slack.com/archives/CD0SF6KD4/p1737024037028519

@MatousMarik MatousMarik added the feature Issues that represent new features or improvements to existing features. label Jan 16, 2025
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Jan 16, 2025
@B4nan B4nan added this to the 4.0 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issues that represent new features or improvements to existing features. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

2 participants