-
Notifications
You must be signed in to change notification settings - Fork 27
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
Hh rm mixins #245
base: master
Are you sure you want to change the base?
Hh rm mixins #245
Conversation
Example use case: You have a multipage app and an SSO load script. |
Update: embedding handlers without prefixes is easy an already included now |
Demo App# Test of `@mixins` from branch hh-rm-mixins (https://github.com/GenieFramework/Stipple.jl/pull/245)
using Stipple, Stipple.ReactiveTools
using StippleUI
@app GreetMixin begin
@in name = "John Doe"
@onchange name begin
println("'name' changed to $(name)!")
end
end greet_handlers
@mounted GreetMixin = "console.log('Just mounted the App including the GreetMixin')"
@methods GreetMixin :greet => "function() { console.log('Hi ' + this.name + '!') }"
@mixins [GreetMixin]
@app begin
@mixin GreetMixin
@in s = "Hi"
@in i = 10
@onchange i begin
println("'i' changed to $(i)!")
end
end
ui() = row(cell(class = "st-module", [
cell(class = "q-my-md q-pa-md bg-green-3", "Name: {{name}}")
cell(class = "q-my-md q-pa-md bg-green-4", "i: {{i}}")
btn("client mixin 'greet'", @click("greet"), color = "red-3", nocaps = true)
btn(class = "q-ml-md", "backend mixin '@onchange name'", @click("name = 'John ' + (name.endsWith('Doe') ? 'Dough' : 'Doe')"), color = "red-3", nocaps = true)
]))
@page("/", ui)
up(open_browser = true) |
After having implemented handlers including prefix and postfix for the current |
Currently we have no possibility of including vue mixins.
This PR uses the existing rendering methods for ReactiveModels and makes it possible of including named apps as mixins.
The idea is to make it easier to develop reusable Plugins.
A demo is given in the doc string of the new macro
@mixins
.@essenciary @PGimenez I made this a draft PR to discuss whether this implementation is sufficient or how we could develop this further.
@mixin
, we would need to define js_methods, etc with optional kwargs pre and post, I suppose.@mixin
macro to call@mixins
. This will currently not work properly without supporting post and prefixes, at least, if the mixins are used like@mixin hh::MyMixin
because that calls@mixin
with a prefix.