Francois
2018-07-24 10:05:50 UTC
Hello,
I have a use case where I want to compose (in the function meaning)
snippet to allows to build plugins.
Basically, I would like to be able to extends / prepend / append other
snippet to the one in the core app.
Let say I have that code:
class CoreAppSnippet extends DispatchSnippet {
 def dispatch = {
   case "appOnly" => appOnly
   case "main"   => appMain
 }
 ...
}
I would like to be able to have an other snippet being able to
contribute that:
class PluginSnippet extends DispatchSnippet {
 def predispatch = {
   case "main" => plugin1
 }
 def postdispatch = {
   case "main" => plugin2
   case "pluginOnly" => pluginOnly
 }
 ...
}
So that the resulting snippet dispatch is logically:
mergedDispatch = {
 case "main" => plugin2(appMain(plugin1)
 case "appOnly" => appOnly
 case "pluginOnly" => pluginOnly
        }
I can do it today by having a special trait for "extendable snippet"
with that logic in place (and with a side pool of "extension snippet"
object, and some key identifier like the class FQN - it's actually
something we do since ~8 years), but I was wondering if there wasn't
something built-in for that ?
Thanks !
--
Francois ARMAND - @fanf42
https://github.com/Normation/rudder
http://www.normation.com
--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I have a use case where I want to compose (in the function meaning)
snippet to allows to build plugins.
Basically, I would like to be able to extends / prepend / append other
snippet to the one in the core app.
Let say I have that code:
class CoreAppSnippet extends DispatchSnippet {
 def dispatch = {
   case "appOnly" => appOnly
   case "main"   => appMain
 }
 ...
}
I would like to be able to have an other snippet being able to
contribute that:
class PluginSnippet extends DispatchSnippet {
 def predispatch = {
   case "main" => plugin1
 }
 def postdispatch = {
   case "main" => plugin2
   case "pluginOnly" => pluginOnly
 }
 ...
}
So that the resulting snippet dispatch is logically:
mergedDispatch = {
 case "main" => plugin2(appMain(plugin1)
 case "appOnly" => appOnly
 case "pluginOnly" => pluginOnly
        }
I can do it today by having a special trait for "extendable snippet"
with that logic in place (and with a side pool of "extension snippet"
object, and some key identifier like the class FQN - it's actually
something we do since ~8 years), but I was wondering if there wasn't
something built-in for that ?
Thanks !
--
Francois ARMAND - @fanf42
https://github.com/Normation/rudder
http://www.normation.com
--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.