Skip to content

Commit 759e9d7

Browse files
authored
Remove outdated scene_ref references (#306)
The `SceneRef` primitive was removed from Scenic in 0.11: https://github.com/ScenicFramework/scenic/pull/239/files#diff-afce33cec4aa7b41757de4ae00f2a89822d56673d2659fec85c40a0ab49f38f9 This removes some references to the removed `SceneRef` primitive from docs and commented code.
1 parent 9af3930 commit 759e9d7

File tree

3 files changed

+0
-135
lines changed

3 files changed

+0
-135
lines changed

guides/scene_lifecycle.md

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,40 +33,6 @@ At some point, depending on your target processor, you will start to have perfor
3333

3434
The good news is that as you switch away to different root scenes, all the old components are automatically cleaned up for you.
3535

36-
37-
## App Supervised Scenes
38-
39-
If you have a component scene that is used by may other scenes, or even in multiple ViewPorts at the same time, you can save memory and reduce load by supervising those scenes yourself.
40-
41-
To do this, create a supervisor in your application and start one or more scenes under it. You can give these scenes names, which is how you will reference them from your graphs.
42-
43-
defmodule MyApp.Scene.Supervisor do
44-
use Supervisor
45-
46-
def start_link() do
47-
Supervisor.start_link(__MODULE__, :ok)
48-
end
49-
50-
def init(:ok) do
51-
children = [
52-
{MyApp.Scene.AppScene, {:some_init_data, [name: :app_scene]}},
53-
{Scenic.Clock.Digital, {[], [name: :clock]}}
54-
]
55-
Supervisor.init(children, strategy: :one_for_one)
56-
end
57-
end
58-
59-
When you build your graphs, you can now use this statically supervised scene directly through the `scene_ref/3` helper in `Scenic.Primitives`.
60-
61-
@graph Graph.build()
62-
|> scene_ref(:app_scene, translate: {300, 300})
63-
|> scene_ref(:clock, translate: {400, 20})
64-
65-
The main trade-off you make when you supervise a scene yourself is that the scene no longer knows which ViewPort it is running in. It could be several at the same time! You will not be able to use functions like `ViewPort.set_root` from these scenes.
66-
67-
The second trade-off is that if the root scene _doesn't_ reference a scene you are supervising yourself, then that scene is still taking up memory in both the scene and the driver even though it isn't being drawn.
68-
69-
7036
## What to read next?
7137

7238
If you are exploring Scenic, then you should read the [Graph Overview](overview_graph.html) next.

lib/scenic/primitives.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ defmodule Scenic.Primitives do
2222
radius :: number
2323
}
2424

25-
# @typep scene_ref ::
26-
# {:graph, reference, any}
27-
# | {module :: atom, init_data :: any}
28-
# | (scene_name :: atom)
29-
3025
@typep sector :: {
3126
radius :: number,
3227
start :: number,

test/scenic/primitives_test.exs

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -531,102 +531,6 @@ defmodule Scenic.PrimitivesTest do
531531
assert p.id == :rounded_rectangle
532532
end
533533

534-
# ============================================================================
535-
# test "scene_ref adds to a graph - default opts" do
536-
# key = {:graph, make_ref(), 123}
537-
538-
# g = Primitives.scene_ref(@graph, key)
539-
# p = g.primitives[1]
540-
541-
# assert p.module == Scenic.Primitive.SceneRef
542-
# assert p.data == key
543-
# end
544-
545-
# test "scene_ref adds graph key reference to a graph" do
546-
# key = {:graph, make_ref(), 123}
547-
548-
# p =
549-
# Primitives.scene_ref(@graph, key, id: :ref)
550-
# |> Graph.get!(:ref)
551-
552-
# assert p.module == Scenic.Primitive.SceneRef
553-
# assert p.data == key
554-
# assert p.id == :ref
555-
# end
556-
557-
# test "scene_ref adds named scene reference to a graph" do
558-
# p =
559-
# Primitives.scene_ref(@graph, :scene_name, id: :ref)
560-
# |> Graph.get!(:ref)
561-
562-
# assert p.module == Scenic.Primitive.SceneRef
563-
# assert p.data == :scene_name
564-
# assert p.id == :ref
565-
# end
566-
567-
# test "scene_ref adds pid scene reference to a graph" do
568-
# p =
569-
# Primitives.scene_ref(@graph, self(), id: :ref)
570-
# |> Graph.get!(:ref)
571-
572-
# assert p.module == Scenic.Primitive.SceneRef
573-
# assert p.data == {self(), nil}
574-
# assert p.id == :ref
575-
# end
576-
577-
# test "scene_ref adds named scene with id reference to a graph" do
578-
# p =
579-
# Primitives.scene_ref(@graph, {:scene_name, 123}, id: :ref)
580-
# |> Graph.get!(:ref)
581-
582-
# assert p.module == Scenic.Primitive.SceneRef
583-
# assert p.data == {:scene_name, 123}
584-
# assert p.id == :ref
585-
# end
586-
587-
# test "scene_ref adds pid with id reference to a graph" do
588-
# p =
589-
# Primitives.scene_ref(@graph, {self(), 123}, id: :ref)
590-
# |> Graph.get!(:ref)
591-
592-
# assert p.module == Scenic.Primitive.SceneRef
593-
# assert p.data == {self(), 123}
594-
# assert p.id == :ref
595-
# end
596-
597-
# test "scene_ref adds dynamic reference to a graph" do
598-
# p =
599-
# Primitives.scene_ref(@graph, {{:mod, "abc"}, 123}, id: :ref)
600-
# |> Graph.get!(:ref)
601-
602-
# assert p.module == Scenic.Primitive.SceneRef
603-
# assert p.data == {{:mod, "abc"}, 123}
604-
# assert p.id == :ref
605-
# end
606-
607-
# test "scene_ref modifies primitive" do
608-
# p =
609-
# Primitives.scene_ref(@graph, {{:mod, "abc"}, 123}, id: :ref)
610-
# |> Graph.get!(:ref)
611-
# |> Primitives.scene_ref({{:new_mod, "abcd"}, 456}, id: :modified)
612-
613-
# assert p.data == {{:new_mod, "abcd"}, 456}
614-
# assert p.id == :modified
615-
# end
616-
617-
# test "scene_ref adds via spec" do
618-
# p =
619-
# @graph
620-
# |> Primitives.add_specs_to_graph([
621-
# Primitives.scene_ref_spec({self(), 123}, id: :scene_ref)
622-
# ])
623-
# |> Graph.get!(:scene_ref)
624-
625-
# assert p.module == Scenic.Primitive.SceneRef
626-
# assert p.data == {self(), 123}
627-
# assert p.id == :scene_ref
628-
# end
629-
630534
# ============================================================================
631535
test "script adds a script to a graph - default opts" do
632536
g = Primitives.script(@graph, "some_script_name")

0 commit comments

Comments
 (0)