Current section

21 Versions

Jump to

Compare versions

4 files changed
+31 additions
-46 deletions
  @@ -7,12 +7,13 @@ while keeping the interactivity.
7 7
8 8 ## Installation
9 9
10 - > NOTE: If you are using LiveView 0.18, please use latest version. If you are still in 0.17 use 0.5.0
11 - > Phoenix 1.7: Make sure to be on 0.5.2 for LV 0.17 or 0.6.3 for LV 0.18.
10 + > Version `0.7.0` drops support for some older versions of Elixir, OTP, Phoenix and Phoenix LiveView. This was done because the current CI matrix generated 24 different builds and just adding OTP 26 would mean duplicating that. Also, removing support for LiveView 0.18.16 drop some code.
12 11
13 12 ```elixir
14 13 def deps do
15 14 [
15 + # If you are using OTP 25 or above, Elixir 1.14, Phoenix 1.7, LiveView 0.19:
16 + {:live_isolated_component, "~> 0.7.0", only: [:dev, :test]}
16 17 # If you are in LV 0.18 or above
17 18 {:live_isolated_component, "~> 0.6.5", only: [:dev, :test]}
18 19 # If you are in LV 0.17
  @@ -1,26 +1,26 @@
1 - {<<"app">>,<<"live_isolated_component">>}.
2 - {<<"build_tools">>,[<<"mix">>]}.
1 + {<<"links">>,
2 + [{<<"GitHub">>,<<"https://github.com/Serabe/live_isolated_component">>}]}.
3 + {<<"name">>,<<"live_isolated_component">>}.
4 + {<<"version">>,<<"0.7.0">>}.
3 5 {<<"description">>,
4 6 <<"Simple library to test LV components live in isolation">>}.
5 - {<<"elixir">>,<<"~> 1.13">>}.
7 + {<<"elixir">>,<<"~> 1.14">>}.
8 + {<<"app">>,<<"live_isolated_component">>}.
9 + {<<"licenses">>,[<<"MIT">>]}.
6 10 {<<"files">>,
7 11 [<<"lib">>,<<"lib/live_isolated_component">>,
8 12 <<"lib/live_isolated_component/store_agent.ex">>,
9 13 <<"lib/live_isolated_component.ex">>,<<"LICENSE.txt">>,<<"mix.exs">>,
10 14 <<"README.md">>]}.
11 - {<<"licenses">>,[<<"MIT">>]}.
12 - {<<"links">>,
13 - [{<<"GitHub">>,<<"https://github.com/Serabe/live_isolated_component">>}]}.
14 - {<<"name">>,<<"live_isolated_component">>}.
15 15 {<<"requirements">>,
16 - [[{<<"app">>,<<"phoenix">>},
17 - {<<"name">>,<<"phoenix">>},
16 + [[{<<"name">>,<<"phoenix">>},
17 + {<<"app">>,<<"phoenix">>},
18 18 {<<"optional">>,false},
19 - {<<"repository">>,<<"hexpm">>},
20 - {<<"requirement">>,<<"~> 1.6.0 or ~> 1.7.0">>}],
21 - [{<<"app">>,<<"phoenix_live_view">>},
22 - {<<"name">>,<<"phoenix_live_view">>},
19 + {<<"requirement">>,<<"~> 1.7.0">>},
20 + {<<"repository">>,<<"hexpm">>}],
21 + [{<<"name">>,<<"phoenix_live_view">>},
22 + {<<"app">>,<<"phoenix_live_view">>},
23 23 {<<"optional">>,false},
24 - {<<"repository">>,<<"hexpm">>},
25 - {<<"requirement">>,<<"~> 0.18.0 or ~> 0.19.0">>}]]}.
26 - {<<"version">>,<<"0.6.5">>}.
24 + {<<"requirement">>,<<"~> 0.19.0">>},
25 + {<<"repository">>,<<"hexpm">>}]]}.
26 + {<<"build_tools">>,[<<"mix">>]}.
  @@ -19,6 +19,8 @@ defmodule LiveIsolatedComponent do
19 19
20 20 use Phoenix.LiveView
21 21
22 + alias Phoenix.LiveView.TagEngine
23 +
22 24 @updates_event "live_isolated_component_update_event"
23 25 @store_agent_key "live_isolated_component_store_agent"
24 26
  @@ -34,12 +36,9 @@ defmodule LiveIsolatedComponent do
34 36 {:ok, socket}
35 37 end
36 38
37 - def render(
38 - %{component: component, store_agent: agent, assigns: component_assigns, engine: engine} =
39 - _assigns
40 - )
39 + def render(%{component: component, store_agent: agent, assigns: component_assigns} = _assigns)
41 40 when is_function(component) do
42 - engine.component(
41 + TagEngine.component(
43 42 component,
44 43 Map.merge(
45 44 component_assigns,
  @@ -97,24 +96,9 @@ defmodule LiveIsolatedComponent do
97 96 socket
98 97 |> assign(:assigns, StoreAgent.get_assigns(agent))
99 98 |> assign(:component, component)
100 - |> assign_engine(component)
101 99 |> assign(:slots, StoreAgent.get_slots(agent))
102 100 end
103 101
104 - # In LiveView 0.18.17 component/3 moved from HTMLEngine to TagEngine.
105 - # This is only used in functional components.
106 - defp assign_engine(assigns, component) when is_function(component) do
107 - engine =
108 - Enum.find([Phoenix.LiveView.TagEngine, Phoenix.LiveView.HTMLEngine], fn mod ->
109 - Code.ensure_loaded?(mod) and function_exported?(mod, :component, 3)
110 - end)
111 -
112 - assign(assigns, :engine, engine)
113 - end
114 -
115 - # Engine is not going to be used in stateful components
116 - defp assign_engine(assigns, _component), do: assigns
117 -
118 102 def handle_info({@updates_event, pid}, socket) do
119 103 values = Agent.get(pid, & &1)
120 104 Agent.stop(pid)
  @@ -1,7 +1,7 @@
1 1 defmodule LiveIsolatedComponent.MixProject do
2 2 use Mix.Project
3 3
4 - @version "0.6.5"
4 + @version "0.7.0"
5 5
6 6 def project do
7 7 [
  @@ -14,7 +14,7 @@ defmodule LiveIsolatedComponent.MixProject do
14 14 app: :live_isolated_component,
15 15 package: package(),
16 16 version: @version,
17 - elixir: "~> 1.13",
17 + elixir: "~> 1.14",
18 18 start_permanent: Mix.env() == :prod,
19 19 deps: deps()
20 20 ]
  @@ -40,12 +40,12 @@ defmodule LiveIsolatedComponent.MixProject do
40 40 # Run "mix help deps" to learn about dependencies.
41 41 defp deps do
42 42 [
43 - {:credo, "~> 1.6.4", only: :dev, runtime: false},
44 - {:mix_test_watch, "~> 1.1.0", only: :dev, runtime: false},
45 - {:dialyxir, "~> 1.1.0", only: :dev, runtime: false},
46 - {:ex_doc, "~> 0.28.4", only: :dev, runtime: false},
47 - {:phoenix, "~> 1.6.0 or ~> 1.7.0"},
48 - {:phoenix_live_view, "~> 0.18.0 or ~> 0.19.0"}
43 + {:credo, "~> 1.7.0", only: :dev, runtime: false},
44 + {:dialyxir, "~> 1.4.1", only: :dev, runtime: false},
45 + {:ex_doc, "~> 0.30.6", only: :dev, runtime: false},
46 + {:mix_test_watch, "~> 1.1.1", only: :dev, runtime: false},
47 + {:phoenix, "~> 1.7.0"},
48 + {:phoenix_live_view, "~> 0.19.0"}
49 49 ]
50 50 end
51 51 end