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

feat: expose edge renderer locals #156

Closed
wants to merge 1 commit into from

Conversation

KABBOUCHI
Copy link

πŸ”— Linked issue

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

i'm creating multiple renderer on the same request, and i want to access existing renderer shared data

const createRenderer = (sharedData) => {
 const renderer = edge.createRenderer()
 
 const view = HttpContext.get().view // AdonisJS Edge Renderer
 renderer.share(view.getLocals()) 
 
 renderer.share(sharedData)
 
 return renderer
}

// isolated instances
const view1 = createRenderer({ a: 1 })
const view2 = createRenderer({ b: 2 })


await view1.render("component1", {
   foo: "bar"
})

await view2.render("componen2t", {
   baz: "qux"
})

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@thetutlage
Copy link
Member

Instead of exposing the locals, how about we allow cloning an existing renderer with its current state?

@thetutlage
Copy link
Member

I have added support for cloning the renderer, which should address your use-case. But, if you think sharing locals is still needed, feel free to comment here :)

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.

4 participants