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

fix: deep nested preact signals in props #11863

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ph1p
Copy link
Contributor

@ph1p ph1p commented Aug 28, 2024

Changes

This extends my work from: #11834 (review)
Now its possible to nest the signals.

If you have this:

---
const count = signal(10);

const dataObj = {
  count,
  deep: {
    signal: count,
    ok: [signal(1), signal(423), 'string'],
    evenDeeper: {
        signal: signal(0),
    },
  },
};

const dataArr = [signal(401), dataObj];
---
<ArrObjSignal dataArr={dataArr} dataObj={dataObj} client:load />

Now the preact signal structure looks like this:

{
  "dataObj":{
    "count":"p1",
    "deep.signal":"p1",
    "deep.ok.0":"p2",
    "deep.ok.1":"p3",
    "deep.evenDeeper.signal":"p4"
  },
  "dataArr": {
    "0":"p0",
    "1.count":"p1",
    "1.deep.signal":"p1",
    "1.deep.ok.0":"p2",
    "1.deep.ok.1":"p3",
    "1.deep.evenDeeper.signal":"p4"
  }
}

Testing

Included.

Docs

nothing should change for the user.

Copy link

changeset-bot bot commented Aug 28, 2024

🦋 Changeset detected

Latest commit: b8ec6b4

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: preact Related to Preact (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Aug 28, 2024
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing

@ph1p ph1p marked this pull request as draft August 29, 2024 12:19
@github-actions github-actions bot added the pkg: example Related to an example package (scope) label Aug 29, 2024
@ph1p ph1p marked this pull request as ready for review August 29, 2024 12:55
@github-actions github-actions bot removed the pkg: example Related to an example package (scope) label Aug 29, 2024
@ph1p
Copy link
Contributor Author

ph1p commented Aug 29, 2024

Ok, I looked at the tests and “Lit components” sometimes fails and sometimes doesn't. This has nothing to do with this change. I also jumped to the current state of the main and there it also happens from time to time.

@ph1p ph1p force-pushed the feature/preact-signals branch 2 times, most recently from 26aca18 to d239fb5 Compare August 29, 2024 14:45
@matthewp
Copy link
Contributor

Yeah I'm sure that's unrelated here.

@matthewp
Copy link
Contributor

matthewp commented Sep 9, 2024

@ph1p would you mind resolving conflicts?

@ph1p
Copy link
Contributor Author

ph1p commented Sep 9, 2024

Sure! But I'm currently on vacation. I'll do it on Saturday if it's ok :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: preact Related to Preact (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants