elixir
2019-08-01 18:28:55   0  举报             
     
         
 AI智能生成
  elixir的自学
    作者其他创作
 大纲/内容
  编译文件    
     iex xxx  
     进入控制台:c "./xxx"  
     框架    
     phoenix    
     par1 building with functional MVC    
     环境安装    
     elixir  
     postgreSql    
     https://postgresapp.com/  
     get Start           
     creating ~/.mix/archives/phx_new  
     Going Deeper: The Request Pipeline
    
     web app as a function    
     Your web applications are pipelines of plugs.  
     function break into Plug library     
     Each plug consumes and produces a common data structure called Plug.Conn  
     each individual plug as a function that takes a conn ,does something samall return a slightly changed conn  
     目录解析    
     assets    
     Browser files     
     js,css  
     config  
     lib    
     long-running processes  
     business logic  
     xx_web    
     web-related mvc templates  
     .ex files    
     compiles to .beam files run on Erlang VM
  
     .exs files    
     Elixir scripts    
     not comlples to .beam  
     Can I Have More Than One Endpoint?  
     highlevel core concepts  
     context    
     A API Layer  
     验证用户    
     依赖    
     comeonin    
     hash 相关  
     pbkdf2_elixir  
     mix phx.gen.context Accounts Credential credentials \ email:string:unique password_hash:string user_id:references:users      
     Deleting a user should also delete the associated credentials so we changed the :on_delete for our :user_id reference from :nothing to :delete_all.  
     语言基础    
     Basic    
     value type    
     String    
     本质上是binary or list type  
     共性  
     #{expression} 插入表达式  
     arbitrary-sized integers    
     多进制  
     1_000_000  
     no fixed limit on the size of integers  
     floating-point numbers  
     atoms  
     rangs  
     reg  
     System types    
     PIDS and ports  
     references  
     类型    
     Collection Types    
     Tuples    
     常见示例  
     Lists    
     Keyword Lists    
     Keyword lists are typically used in the context of options passed to functions.  
     深入理解LIST  
     Maps    
     API  
     update Map    
     %{ old_map | key => value, ... } 本身不增加key  
     增加key字段    
     Map.put_new/3  
     如何选择 Map,Structs,KW LIst    
     要用模式匹配    
     map  
     than one entry with the same key?    
     keyword  
     元素是有序的    
     keyword  
     固定的某几个元素    
     struct  
     ^ pin  in map  
     两种表示    
     冒号     
     %{"G": "C", "C": "G", "T": "A", "A": "U"}  
     =>    
     %{"G" => "C", C => "G", T => "A", A => "U"}  
     如果你没key没加双引号 就会变成atom  
     Sets    
     API  
     Structs    
     a limited form of map.    
     the keys must be atoms  
     don’t have Dict capabilities.  
     maps的扩展:编译时的检查+默认值    
     错误示范  
     为啥wrapped in a module    
     如果你想添加struct-specific behavior  
     defstruct  
     A struct is a map that has a __struct__ key:  
     由来  
     Inside the module, you use the defstruct macro to define the struct’s members.  
     TypeCheck Function  
     函数    
     匿名函数  
     参数传递 !asign 而是 Pattern Matching  
     一个函数,多个函数体    
     :file.format_error  
     The & Notation    
     {},[]也是操作符  
     常见例子  
     一等公民    
     函数可以被函数返回  
     函数可以作为参数传递  
     函数参数 & pinned values  
     Functions Remember Their Original Environment    
     和闭包很像嘛  
      Named Functions    
     特征  
     do end 语法糖  
     函数调用    
     基础参数个数  
     基于参数类型  
     默认参数    
     参数少传了不可以  
     私有函数  
     The Amazing Pipe Operator: |>    
     理念  
     do end 内部是 do:  
     Modules    
     The import Directive  
     The alias Directive  
     Module Attributes    
     meta data  
     Compiling a Module    
     iex xxx.exs  
     c xxx.exs    
     If you’re already in IEx, you can use the c helper to compile your file without returning to the command line.  
     when关键字           
     List And Recursion    
      recursion is a perfect tool for processing lists  
     split a list into its head and its tail  
     [ head | tail ] = [ 1, 2, 3 ]  
     示例  
     head匹配多个元素  
     标准库List    
     ++  
     flatten  
     folding  
     replace_at  
     keyfind  
     7.5 嵌套的结构  
     ProcessingCollections-Enum and Stream    
     Enum常见Api  
     Stream  
     并发编程    
     递归调用    
     尾递归调用  
     尾递归优化  
     转化成尾递归  
     进程相关    
     开启进程    
     spawn  
     进程的交互    
     send  
     receive  
     进程的结束  
     关联两个进程    
     子主题  
     监控进程  
     并行map    
     子主题  
     斐波那契服务器  
     Nodes  
     OTP    
     服务器  
     应用程序监视器  
     应用程序  
     任务代理  
     模式匹配    
     Map    
     按key Or value  
     Pattern Matching Can’t Bind Keys  
     pin operator  
     immutable           
     优点    
     side-effect-free functions  
     data consistency  
    
 
 
 
 
  0 条评论
 下一页
 为你推荐
 查看更多