-
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
Uncomponentisation and Universalisation? #34
Comments
We are super happy to have you around.
We can't take full credit for that idea.
Well, that makes a lot of sense. Using If I understand your goals in un correctly the intention is that one can write components that have no dependencies on any framework? I think that sounds cool. But doesn't it add some severe restrictions to the type of architecture one can implement? |
Thank you, that means a lot to me!
I think I had in mind the idea to use it for multiple outputs coming out from a UI component. That have a "parallel" flavour comparing to the Haskel's sequential But now that you mention the In which case, simply reducing all role to the same looking generator function, may lead to a loss of its role. What I mean is that sometimes you may actually want the proper generator functionality, sometimes you want to use it with the And if the answer is yes, it would have its place along with other core API: const view = ({ div, span, input, go }) => go(function* () { .... }) which could be again exported with no dependency. But now that you mentioned Monadic structure, const main = () =>
span("Please enter an email address: ")
.chain(() => input())
.map(({inputValue}) => map(isValidEmail)(inputValue))
.chain(valid => div([
"The address is ",
valid ? 'valid' : 'invalid'
])) Would it work?
Perhaps I will run into more difficulties later on, but at this stage, when I am still shaping the ideas, it does not feel so much of a problem. Not yet. :) There is the same pattern I can see across various frameworks, where you always have views mapping state into dom and models responsible for updating the state. So it feels natural to leverage this and encapsulate in the same architecture pattern, at least at this level of abstraction. But otherwise, anywhere else, I like the idea of giving the complete freedom how to write the views and models. So with Turbine, you would even use the generators sometimes wrapped into their specific roles. And internally, there wouldn't be any restrictions at all. You would write exactly the same code as you would write anyway. And some people may prefer to carry their dependencies along rather than export them as parameters, which is fine. Of course, that would add some rigidity and limit the "internal universality" of your components. By which I mean e.g. using the But you can still keep the "external universality" for your Turbine components, that is the ability to plug them into outside frameworks. And only at the very top root level, your component would need to conform to some pattern. For instance, to be used inside a larger React app, you would wrap your Turbine component as React's one and then use it the normal way without even noticing the difference. And you can write Turbine's components with advanced functionality, that people can use in React without even paying attention :) The only API you would need to connect with React is a Renderer, I'd be very curious to hear your opinion, if that makes sense, |
BTW, here is how I would see a possible way to embed So all that can be done in simple-minded redux-style way, These could even be React or other framework functional components. Then once mounted as Turbine's component, full control is passed to the Turbine. |
Yes, indeed. That example should work. In fact, one can always rewrite Turbine code to eliminate the use of generator functions. They are not essential. But they make things a lot easier 😄
I am not sure what you means that the should be several roles for the generator functions? In all cases, the generator functions do the same thing. They're sugar for calling |
Ah, that is good to know ;) Even for that example, I'd find it "tolerably" awkward if I writing as input()
.chain( ({ inputValue: a }) => input()
.chain( ({ inputValue: b }) => span(["Combined text: ", a, b]) ).
) Of course, you only need nesting when the current function needs But what is less clear is what is div(`Hello`)
.chain( a => div( ... ) ) Something like Yes, any further explanation for topics such as generators helps, It might also be good to give the link to Jabz for more details on the About the roles of generators, I was thinking of the use case Does it make sense? |
div(`Hello`)
.chain( a => div( ... ) )
The element is part of the
I think that is an interesting idea and it would be exciting to explore. But for now, in Turbine, I think we should try to focus on using generators as normal do-notation. Generators are already confusing enough and I like that we can explain that they only do one single and pretty simple thing (i.e. call |
(It is perhaps by now clear that)
I find this library really interesting and inspiring.
I have never seen the use of generators in this fashion,
if just one new idea to be mentioned, among others.
I really would like to leverage the
un
projectto make it even more accessible and pluggable.
So anyone can try the
Turbine
with a simple piece of code,and then instantly plug and use inside any existing working application.
Uncomponentisation
Specifically, what I mean by "uncomponent" here is to enable this example
to be written as pure generator with no external dependency:
It is almost the same but now can be used and tested anywhere in its purity.
It would be recognised and packaged with
go
internally by the Turbineat the runtime.
Universality
What I mean by universality is to be able to plug this into any application.
Here is how the
un
tries to make it work:Use the
mount
function to run a Turbine's component directly in DOM:or embed it anywhere into any framework:
Here is an example of the working code
Here is what I think is needed to make it possible:
createElement
function to compile the user uncomponents into Turbine componentscreateRender
function to run the componentIt would be great to hear what you think about it.
The text was updated successfully, but these errors were encountered: