Permalink
Browse files

Add typespecs and deprecation attributes

  • Loading branch information...
geolessel committed Mar 14, 2018
1 parent 4be9020 commit a8812edf3bafeeb262497b2c0dad948e13247eef
Showing with 17 additions and 12 deletions.
  1. +2 −0 lib/react_phoenix.ex
  2. +6 −3 lib/react_phoenix/client_side.ex
  3. +1 −0 mix.exs
  4. +8 −9 mix.lock
View
@@ -9,6 +9,7 @@ defmodule ReactPhoenix do
As of v0.4.0, please use `ReactPhoenix.ClientSide.react_component/2` instead. Provided for backward
compatability for versions < 0.4.0.
"""
@deprecated "Use ReactPhoenix.ClientSide.react_component"
def react_component(name, props \\ %{}),
do: ReactPhoenix.ClientSide.react_component(name, props)
@@ -18,6 +19,7 @@ defmodule ReactPhoenix do
As of v0.4.0, please use `ReactPhoenix.ClientSide.react_component/3` instead. Provided for backward
compatability for versions < 0.4.0.
"""
@deprecated "Use ReactPhoenix.ClientSide.react_component"
def react_component(name, props, opts),
do: ReactPhoenix.ClientSide.react_component(name, props, opts)
end
@@ -25,6 +25,7 @@ defmodule ReactPhoenix.ClientSide do
The resulting `<div>` tag is formatted specifically for the included javascript
helper to then turn into your named React component.
"""
@spec react_component(name :: String.t) :: Phoenix.HTML.safe
def react_component(name), do: react_component(name, %{})
@doc """
@@ -43,6 +44,7 @@ defmodule ReactPhoenix.ClientSide do
The resulting `<div>` tag is formatted specifically for the included javascript
helper to then turn into your named React component and then pass in the props specified.
"""
@spec react_component(name :: String.t, props :: list | map) :: Phoenix.HTML.safe
def react_component(name, props) when is_list(props) do
react_component(name, Enum.into(props, %{}))
end
@@ -66,15 +68,16 @@ defmodule ReactPhoenix.ClientSide do
```
<%= ReactPhoenix.ClientSide.react_component(
"MyComponent",
%{language: "elixir", awesome: true},
target_id: "react-div"
"MyComponent", # <- component name
%{language: "elixir", awesome: true}, # <- props
target_id: "react-div" # <- options
) %>
```
The resulting `<div>` tag is formatted specifically for the included javascript
helper to then turn into your named React component and then pass in the props specified.
"""
@spec react_component(name :: String.t, props :: map, opts :: [target_id: String.t]) :: Phoenix.HTML.safe
def react_component(name, props, opts) when is_map(props) do
props = Poison.encode!(props)
View
@@ -32,6 +32,7 @@ defmodule ReactPhoenix.Mixfile do
defp deps do
[
{:ex_doc, ">= 0.0.0", only: :dev},
{:dialyxir, "~> 0.5", only: :dev},
{:phoenix_html, "~> 2.9"},
{:poison, "~> 2.2 or ~> 3.0"}
]
View
@@ -1,10 +1,9 @@
%{"earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.15.1", "d5f9d588fd802152516fccfdb96d6073753f77314fcfee892b15b6724ca0d596", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []},
"mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], []},
"phoenix_html": {:hex, :phoenix_html, "2.9.3", "1b5a2122cbf743aa242f54dced8a4f1cc778b8bd304f4b4c0043a6250c58e258", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
"plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
%{
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], []},
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.18.3", "f4b0e4a2ec6f333dccf761838a4b253d75e11f714b85ae271c9ae361367897b7", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
"mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [:mix], []},
"phoenix_html": {:hex, :phoenix_html, "2.11.0", "ead10dd1e36d5b8b5cc55642ba337832ec62617efd5765cddaa1a36c8b3891ca", [:mix], [{:plug, "~> 1.5", [hex: :plug, optional: false]}]},
"plug": {:hex, :plug, "1.5.0", "224b25b4039bedc1eac149fb52ed456770b9678bbf0349cdd810460e1e09195b", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},
"porcelain": {:hex, :porcelain, "2.0.3", "2d77b17d1f21fed875b8c5ecba72a01533db2013bd2e5e62c6d286c029150fdc", [:mix], []},
"std_json_io_2": {:hex, :std_json_io_2, "0.2.0", "208ae14f548e662125136921269456e026c692535c1946b173fa7e4549f5aa23", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, optional: false]}, {:poison, "~> 3.0", [hex: :poison, optional: false]}, {:poolboy, "~> 1.5.1", [hex: :poolboy, optional: false]}, {:porcelain, "~> 2.0.3", [hex: :porcelain, optional: false]}]}}
}

0 comments on commit a8812ed

Please sign in to comment.