Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 01 10:11

    5HT on master

    hte (compare)

  • Mar 27 00:56

    5HT on master

    Add support for bind in #input{… (compare)

  • Mar 27 00:56
    5HT closed #46
  • Mar 27 00:55
    umka1332 opened #46
  • Mar 27 00:52

    umka1332 on hidden-with-bind

    Add support for bind in #input{… (compare)

  • Mar 24 10:42

    5HT on master

    5.3.0 (compare)

  • Mar 23 16:21

    IrinaKostiuk on master

    delete nitro:jse(Val) (compare)

  • Feb 28 08:47

    5HT on master

    Fix url (compare)

  • Feb 28 08:47
    5HT closed #346
  • Feb 28 08:47
    osbre opened #346
  • Feb 26 15:54

    5HT on master

    index (compare)

  • Feb 18 15:34

    5HT on master

    Fix n2o.pi example Update n2o_pi.htm (compare)

  • Feb 18 15:34
    5HT closed #345
  • Feb 18 15:08

    umka1332 on umka1332-patch-1

    Update n2o_pi.htm (compare)

  • Feb 18 15:08
    umka1332 synchronize #345
  • Feb 17 13:23
    umka1332 opened #345
  • Feb 17 13:23

    umka1332 on umka1332-patch-1

    Fix n2o.pi example (compare)

  • Feb 14 09:38

    5HT on master

    Fix for 'attach' script Withou… (compare)

  • Feb 14 09:38
    5HT closed #108
  • Feb 14 09:38
    5HT commented #108
Namdak Tonpa
@5HT
N2O makes reliable WS connection and provides BERT encoding
NITRO renders pages and provides SPA page signaling protocol (Nitrogen Web Framework in terms of Erlang API) on top of N2O BERT raw channel
N2O/NITRO stack introduce zero-overhead in terms of Erlang processes on top of COWBOY
Thereby we use raw COWBOY router and introduce no ours
N2O core consists of TWO callback functions:
  1. info/3 (message, query, #cx{}) for N2O contexts
  2. proc/2 (message, #pi{}) for Process Instance (SYNRC gen_server replacement)
info is for N2O protocols
proc is for Erlang protocols (native Erlang processes without sockets and encodings)
By combaning them you create your own application topology
Namdak Tonpa
@5HT
E.g. FTP protocol spawns proc/2 per each file, while all starts stops and chunks are being passed first to info/3 as N2O protocol entry point
BPE protocols also could/should spawn proc/2 per business process, etc.
N2O Expire timer implemented as proc/2
I believe you got the idea. so PI is just gen_server replacement in our stack
while N2O protocol is a part of socket handlers (n2o protocols) chain
we specify list of N2O protocols in {n2o,protolos} env variable
> :application.get_env(:n2o,:protocols)
{:ok, [:nitro_n2o, :crm_ftp, :n2o_heart]}
as you may see my N2O instance contains three protocols (servlets in terms of Java) on top of each socket listener
that's are socket entry points
each of these modules expose info/3 functions
Kool Quark
@koolquark
@5HT , thanks . I will update once I progress through my project. This framework allows us to write everything in Erlang which is a great advantage.
Namdak Tonpa
@5HT
The idea behing N2O/NITRO is to have constant size 5K js for everything (DOM manipulations) with zero-overhead on server side (you don't need to preprocess messages from JS, they are already BERT)!
Why you still can use any templater, DTL or any external library, they are just not needed, because you have native Erlang templater which is NITRO Elements API
on top of NITRO we also have FORM layer where you can declare UI and not to code it :-) for ERP.UNO apps
Namdak Tonpa
@5HT
BPE is an engine where FORMs are being passed for user to input on each transactional step, that's how we build ERP apps
as NITRO the only component for DOM manipulations we have BPE as the only component for backend software
BPE provides action/2 (message, #process{})
Each N2O lib has such callback action that hides some N2O protocol
NITRO has event/1 (message) API as Nitrogen legacy, with implicit #cx{} inside Erlang process dictionary
Kool Quark
@koolquark

I am trying to render html from nitro ; how do we render following snippet ;

 <p>
   Dashboard
   <i class="right fas fa-angle-left"></i>
 </p>
#p{ body = [ #WhatElementGoesHere ..  , 
             RecordFor<i> 
           ] 
  }.

For <i> I can use

#element{html_tag = <<"i">> , class = <<"fas fa-angle-left">> body = <<"">> }
Kool Quark
@koolquark
Figured out that :
#p{ body = [ #literal{body = "Dashboard"},
             #element{html_tag = <<"i">> class = <<"fas fa-angle-left">> body = <<"">>}
           ] 
  }.
that should work
Namdak Tonpa
@5HT
Yes, #i, #b elements was removed due to var interference with local variables i, b in Elixir
class could be rewritten as class = ['fas', 'fa-angle-left'] which looks more bold
also body = []
it already has =[] as default so could be ommited
you can bring back those records by introducing them in this way:
-record(i, ?DEFAULT_BASE).
-record(b, ?DEFAULT_BASE).
after that you can write:
#'div'{ body = [ #b{ body = "Text"}, #i{body = "Text"} ]}
Kool Quark
@koolquark
Ok, class as list is better to read.
In nitro can we just update some attributes of element without replacing it . When we do nitro:update are we not replacing the element identified by the id.
?
Kool Quark
@koolquark

In my initial loaded index.htm I have

    <li class="nav-item">
       <a id="sbSRNew" href="#" class="nav-link active">
        <i class="far fa-circle nav-icon"></i>
        <p>New Request</p>
       </a>
    </li>

What I would like do is just update the postback for
element sbSRNew . Currently when I use nitro:update,
I think I have to construct the entire segment ie the full <a>
using nitro records. Is there any way to just update the postback
attribute only ? .

Namdak Tonpa
@5HT
The answer is no, when you need to update DOM with postback you usually replace full dom with its recursive reinitialization.
 nitro:update(sbSRNew, 
    #link{id="sbSRNew", href="#", class=['nav-link','active'],
          postback={mypost}, body = [#i{...},#p{...}]})
Namdak Tonpa
@5HT
But there is a possibility to deliver only postback, we need just to implement new nitro API or snippet.
basically you need to emit NITRO.event
-module(action_event).
-include_lib("nitro/include/nitro.hrl").
-include_lib("nitro/include/event.hrl").
-compile(export_all).
-define(B(E), nitro:to_binary(E)).

render_action(#event{source=undefined}) -> [];
render_action(#event{postback=Postback,actions=_A,source=Source,
                     target=Control,type=Type,delegate=D,validation=V}) ->
    E = ?B(Control),
    ValidationSource = [ S || S <- Source, not is_tuple(S) ],
    PostbackBin = wf_event:new(Postback, E, D, event, data(E,Source), ValidationSource, V),
    ["{var x=qi('",E,"'); x && x.addEventListener('",?B(Type),
     "',function (event){ event.preventDefault(); ",PostbackBin,"});};"].

data(E,SourceList) ->
    Type=fun(A) when is_atom(A)   -> [ "atom('",atom_to_list(A),"')" ];
            (A) when is_binary(A) -> [ "bin('",binary_to_list(A),"')" ];
                              (A) -> [ "string('",A,"')" ] end,
    list_to_binary(["[tuple(tuple(string('",E,"'),bin('detail')),[])",
        [ case S of {Id,Code} -> [ ",tuple(",Type(Id),",",Code,")" ];
                            _ -> [ ",tuple(",Type(S),",querySource('",?B(S),"'))" ]
          end || S <- SourceList ],"]"]).
This is postback delivery.
As you can see the only requirement is presence of DOM element in DOM tree