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

Build guide: zome functions and lifecycle callbacks #512

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

Conversation

pdaoust
Copy link
Collaborator

@pdaoust pdaoust commented Jan 15, 2025

Two pages here, with some cleanup/extra examples on the CRUD pages now that we've described the call-zome lifecycle and relaxed chain top ordering in detail. Depends on #511 and shouldn't be merged until that one is merged.

@pdaoust pdaoust requested review from mattyg and c12i January 15, 2025 21:45
@pdaoust
Copy link
Collaborator Author

pdaoust commented Jan 15, 2025

Closes #491 , #493 , #496, and #510 . I guess I didn't keep the scope of this one so tidy.

@pdaoust pdaoust marked this pull request as draft January 15, 2025 22:18
@pdaoust
Copy link
Collaborator Author

pdaoust commented Jan 15, 2025

Converting to draft cuz I discovered a code example that got left unwritten 😬

@pdaoust pdaoust marked this pull request as ready for review January 20, 2025 18:45

Here's an `init` callback that [links](/build/links-paths-and-anchors/) the [agent's ID](/build/identifiers/#agent) to the [DNA hash](/build/identifiers/#dna) as a sort of "I'm here" note. (It depends on a couple things being defined in your integrity zome; we'll show the integrity zome after this sample for completeness.)

```rust
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I struggled to find a meaningful init callback example; this is about as minimal as I can think of for the "link agent ID to well-known hash" use case.

// You don't need to tell Holochain about it with the `hdk_entry_types` macro,
// because it never gets stored -- we only use it to calculate a hash.
#[hdk_entry_helper]
pub struct Anchor(pub Vec<u8>);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm trying to avoid paths and anchors here, to reduce complexity, but maybe they're not as complex as all that. I'll go check the API and consider it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant