🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
Voldenet SmokeMachine: for sessions I'd go php way of pre-defining session requirement per method and magic variable for it: `method RENDER($_) is using-session { $*session<Thing> = 42; }` 01:13
because router needs to know whether to use set session cookie before returning any result 01:14
in fact, default configuration for app could decide what's the default 01:15
> root-component App.new, :using-session > root-component App.new, :not-using-session
Voldenet Other way would be to specify endpoints metadata with generic extensions, then adding session extension with strongly-typed classes 01:19
`class Storage { has Int $.blah is rw; }; root-component App.new, :oprions(Session.with(Storage), OpenID.with($oid-provider))); class Component { RENDER($_) { .ext[0].blah = 42; say .ext[1].me } }` 01:26
`RENDER($_) is skipping-extension(0)` 01:27
Voldenet That by-index could be difficult to maintain, but with proper machinery: `class Session { my $ext-metadata = reserve-extension; method get($ext) { $ext.get($ext-metadata) } }; RENDER($_) { Session.get(.ext).blah = 42 }` 01:33
or `Session[::T]` 01:34
it's tempting to use maps everywhere, but it's impossible to make it faster later without refactoring 01:35
In fact, if the first extension would always be hashmap, then it could be made faster simply by rewriting extensions, so `RENDER($_) { .ext(Session[Storage]).blah = 42 }` would look the same without and with optimized lookups 01:38
Voldenet Either way, that's just my idea for how sessions should look like – you define that session's going to hold X and Y - this helps when keeping sessions persisted, because when structure of data in production changes, deserialization can take care of missing properties 01:43
SmokeMachine I just started playing with form generation and I think that's looking good... (github.com/FCO/HTML-Component/blob...kumod#L18) it also accepts a 2nd positional value with a Associative with values to populate the form... 01:44
SmokeMachine Voldenet: thanks for your suggestion! I'll take a read and try to understand it and see what I think about those suggestions... tomorrow (if I have some time) I'll try to write a PoC about that... 01:45
Voldenet np, don't know how much of it will be useful, because it makes the whole thing a lot more complex, first thought of `$*session<Thing>` feels easy to do most things with 01:46
and it mimicks php's $_SESSION 01:47
SmokeMachine about the form, I still have to find a way to auto populate (and show errors). in case it went to a POST endpoint, got errors, it should, probably, show the form with the data and the errors...
Voldenet btw, with that `.form` it'd be easy to make testing all endpoints easy with `for new-todo.^methods -> $m { .form $m }`, which is something very much resembling swagger ui 01:50
Voldenet but awfully easy to implement compared to writing openapi schema 01:52
SmokeMachine Good point… I haven’t thought about that 01:53
Voldenet being able to test endpoints easily is crucial for app developers after all 01:55
Btw regarding the pre-filled forms on render, there might be some values (password, repeated-password) that probably would need to be re-typed on error, but I don't know what the code should be 01:57
`is no-fill` or `.form: self.new-todo, :skip(*.password, *.repeated-password)` 01:58
SmokeMachine I think inputs of type password should do that by default… and maybe something like: is ignore-value… what do you think? 02:03
Voldenet Makes sense, and keep-value being default for everything else 02:26
SmokeMachine Voldenet: about `for new-todo.^methods -> $m { .form $m }`, I'll probably implement a way to return all the endpoints instead of all methods (that may have methods that are not endpoints...) 08:16
Voldenet …certainly, that would be including my favourite BUILDALL endpoint 09:21