Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change @reactive to @vars #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AdvancedExamples/ContourPlots/heatlab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using DataFrames

include("lib/solver.jl") # get_data from solver.jl

@reactive mutable struct HeatPages <: ReactiveModel
@vars HeatPages begin
tableData::R{DataTable} = DataTable(DataFrame(1000 * ones(10, 10), ["$i" for i in 1:10]))
credit_data_pagination::DataTablePagination = DataTablePagination(rows_per_page=10)

Expand Down
2 changes: 1 addition & 1 deletion AdvancedExamples/ServerSideFiltering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Stipple: js_methods

using Random

@reactive! mutable struct Example <: ReactiveModel
@vars Example begin
select::R{Vector{String}} = String[]
options::R{Vector{String}} = ["Options 1", "Options 2", "Options 3"]
filter::R{String} = ""
Expand Down
2 changes: 1 addition & 1 deletion AdvancedExamples/Stipple2048.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ css() = style(media="screen","""
}
""")

@reactive! mutable struct G2048 <: ReactiveModel
@vars G2048 begin
score::R{Int} = 0
bitboard::R{Bitboard} = G.initbboard()
lastboard::R{Bitboard} = Bitboard(0), READONLY
Expand Down
2 changes: 1 addition & 1 deletion AdvancedExamples/Stipple2048_animated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Stipple.@kwdef mutable struct Tile
style::String = ""
end

@reactive! mutable struct G2048 <: ReactiveModel
@vars G2048 begin
score::R{Int} = 0
bitboard::R{Bitboard} = G.initbboard()
lastboard::R{Bitboard} = Bitboard(0), READONLY
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/BubbleCharts/BubbleCharts.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Stipple, StipplePlotly

@reactive mutable struct Model <: ReactiveModel
@vars Model begin
marker::PlotDataMarker =
PlotDataMarker(opacity = [1, 0.8, 0.6, 0.4], size = [40, 60, 80, 100])

Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/CSVUploadProcess/CSVUploadProcess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
const FILE_PATH = create_storage_dir("Backend_Upload")

# Define reactive model
@reactive mutable struct IrisModel <: ReactiveModel
@vars IrisModel begin
iris_data::R{DataTable} = DataTable(data)
credit_data_pagination::DataTablePagination =
DataTablePagination(rows_per_page=50)
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/Card/Card.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using StippleUI

# CardDemo definition inheriting from ReactiveModel
# Base.@kwdef: that defines keyword based contructor of mutable struct
@reactive mutable struct CardDemo <: ReactiveModel end
@vars CardDemo begin

function ui(model)
[
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/Checkboxes/Checkboxes.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple
using StippleUI

@reactive mutable struct Model <: ReactiveModel
@vars Model begin
valone::R{Bool} = false
valtwo::R{Bool} = false
valthree::R{Bool} = false
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/Checkboxes/CheckboxesVector.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StippleUI
using OffsetArrays

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
valone::R{Bool} = false
valtwo::R{Bool} = false
valthree::R{Bool} = false
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/CsvUpload/CSVUpload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end
# Generate file path
const FILE_PATH = create_storage_dir("Backend_Upload")
# Define react model
@reactive mutable struct APP <: ReactiveModel end
@vars APP begin

function ui(model::APP)
page(model, title="Dashboard",
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/DatePickers/DatePickers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Stipple.Html: div

# R{Date}, R{Vector{DateRange}} etc are type Observable and you can listen for changes
# https://juliagizmos.github.io/Observables.jl/stable/
@reactive mutable struct DatePickers <: ReactiveModel
@vars DatePickers begin
date::R{Date} = today() + Day(30)
dates::R{Vector{Date}} = Date[today()+Day(10), today()+Day(20), today()+Day(30)]
daterange::R{DateRange} = DateRange(today(), (today() + Day(3)))
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/Editor/Editor.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StippleUI
import Stipple.opts

@reactive! mutable struct Test <: ReactiveModel
@vars Test begin
s_editor::R{String} = "What you see is <b>what</b> you get."
myfont::R{Dict{Symbol, Any}} = opts(
arial = "Arial",
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/FileUpload/FileUpload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Genie.config.cors_allowed_origins = ["*"]

const FILE_PATH = "upload/file.jpg"

@reactive mutable struct Model <: ReactiveModel end
@vars Model begin

#== view ==#
function ui(model)
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/Form/Form.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Stipple, StippleUI

@reactive mutable struct FormComponent <: ReactiveModel
@vars FormComponent begin
name::R{String} = ""
age::R{Int} = 0
objects::R{Vector} = ["Dog", "Cat", "Beer"]
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/HelloPie/HelloPie.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple
using StippleCharts

@reactive mutable struct HelloPie <: ReactiveModel
@vars HelloPie begin
plot_options::R{PlotOptions} = PlotOptions(
chart_type = :pie,
chart_width = 380,
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/ImageGallery/ImageGallery.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function handlers(model)
model
end

@reactive mutable struct Model <: ReactiveModel
@vars Model begin
url::R{String} = "https://placeimg.com/500/300/nature"
refresh::R{Bool} = false
end
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/StippleButtons/StippleButtons.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple
using StippleUI

@reactive! mutable struct SBModel <: ReactiveModel
@vars SBModel begin
clicks::R{Int} = 0
value::R{Int} = 0
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mycss() = [

add_css(mycss)

@reactive! mutable struct TableDemo <: ReactiveModel
@vars TableDemo begin
table::R{DataTable} = DataTable()

downloadbutton::R{Bool} = false
Expand Down
2 changes: 1 addition & 1 deletion BasicExamples/Tree/EditableDict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function dict_tree(startfile; parent = "d", name = "d")
end


@reactive! mutable struct TreeDemo <: ReactiveModel
@vars TreeDemo begin
d::R{Dict{String, Any}} = deepcopy(testdict)
tree::R{Vector{Dict{Symbol, Any}}} = [dict_tree(testdict)]

Expand Down
4 changes: 2 additions & 2 deletions BasicExamples/Tree/Tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end

cd(dirname(@__DIR__))

@reactive! mutable struct TreeDemo <: ReactiveModel
@vars TreeDemo begin
name::R{String} = ""
files::R{Vector{Dict{Symbol, Any}}} = [filedict(pwd())]
files_selected::R{String} = ""
Expand All @@ -37,7 +37,7 @@ end
# this will work with StippleUI v0.19.3 or latest master

register_mixin(@__MODULE__)
@reactive! mutable struct TreeDemo <: ReactiveModel
@vars TreeDemo begin
name::R{String} = ""
@mixin files::TreeSelectable([filedict(pwd())])
end
Expand Down
2 changes: 1 addition & 1 deletion GermanCredits/GermanCredits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cd(@__DIR__)
data = CSV.File("data/german_credit.csv") |> DataFrame

# Defining a Stipple ReactiveModel of type observable
@reactive mutable struct Dashboard1 <: ReactiveModel
@vars Dashboard1 begin
credit_data::R{DataTable} = DataTable()
credit_data_pagination::DataTablePagination = DataTablePagination(rows_per_page=100)
credit_data_loading::R{Bool} = false
Expand Down
2 changes: 1 addition & 1 deletion IrisClustering/IrisClustering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DataFrames

data = DataFrames.insertcols!(dataset("datasets", "iris"), :Cluster => zeros(Int, 150))

@reactive mutable struct IrisModel <: ReactiveModel
@vars IrisModel begin
iris_data::R{DataTable} = DataTable(data)
credit_data_pagination::DataTablePagination =
DataTablePagination(rows_per_page=50)
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/3DPlots/Plot3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pd1 = PlotData(

plot_data = [pd1]

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = plot_data, READONLY
layout::R{PlotLayout} = PlotLayout(
plot_bgcolor = "#999",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/PlotData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pd(name) = PlotData(
name = name,
)

@reactive mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = [pd("Random 1"), pd("Random 2")]
layout::R{PlotLayout} = PlotLayout(
plot_bgcolor = "#333",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/PlotData2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pd(name) = PlotData(
name = name
)

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = [pd("Random 1"),pd("Random 2")]
layout::R{PlotLayout} = PlotLayout(
plot_bgcolor = "#333",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/PlotlyBaseBar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trace2 = PlotlyBase.bar(x=["giraffes", "orangutans", "monkeys"],
y=[12, 18, 29],
name="LA Zoo")

@reactive! mutable struct BarPlot <: ReactiveModel
@vars BarPlot begin
data::R{Vector{GenericTrace}} = [trace1, trace2]

my_layout::R{PlotlyBase.Layout} = PlotlyBase.Layout(;barmode="stack")
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/PlotlyBaseDemo.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StipplePlotly
using PlotlyBase

@reactive! mutable struct Example <: ReactiveModel
@vars Example begin
plot::R{Plot} = Plot()
end

Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/PlotlyBaseEvents.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StipplePlotly
using PlotlyBase

@reactive! mutable struct Example <: ReactiveModel
@vars Example begin
plot1::R{Plot} = Plot()
plot1_selected::R{Dict{String, Any}} = Dict{String, Any}()
plot1_hover::R{Dict{String, Any}} = Dict{String, Any}()
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/example1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pd(name) = PlotData(

#== reactive model ==#

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = [pd("Random 1"),pd("Random 2")]
layout::R{PlotLayout} = PlotLayout(
plot_bgcolor = "#333",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/example2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pd(name) = PlotData(
name = name
)

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = [pd("Random 1"),pd("Random 2")]
layout::R{PlotLayout} = PlotLayout(
plot_bgcolor = "#333",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/groupedbar1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ layout = PlotLayout(barmode="group", font=Font(16),
yaxis = [PlotLayoutAxis(xy = "y", index = 1, ticks = "outside", title="ratio (%)", font=Font(size=24), autorange=false, range=[70.0,100.0], showline = true, zeroline = false)]
)

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = plotdata, READONLY
layout::R{PlotLayout} = layout, READONLY
config::R{PlotConfig} = PlotConfig(), READONLY
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/maps/CHOROPLETH.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Stipple, StipplePlotly
data = CSV.read(download("https://raw.githubusercontent.com/plotly/datasets/master/2010_alcohol_consumption_by_country.csv"), DataFrame)


@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{PlotData} = PlotData(
plot = StipplePlotly.Charts.PLOT_TYPE_CHOROPLETH,
locationmode = "country names",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/maps/lines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for i in 1:length(scl)
push!(data, current)
end

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = data
layout::R{PlotLayout} = PlotLayout(
geo = PlotLayoutGeo(
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/maps/mapbox_access_token.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StipplePlotly


@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{PlotData} = PlotData(
plot = StipplePlotly.Charts.PLOT_TYPE_CHOROPLETHMAPBOX,
name = "US States",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/maps/scattermap.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StipplePlotly


@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{PlotData} = PlotData(
locations= ["FRA", "DEU", "RUS", "ESP"],
plot = StipplePlotly.Charts.PLOT_TYPE_SCATTERGEO,
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/maps/scattermapbox.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Stipple, StipplePlotly


@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{PlotData} = PlotData(
plot = StipplePlotly.Charts.PLOT_TYPE_SCATTERMAPBOX,
fill = "toself",
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/multitype1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pl() = PlotLayout(
annotations = [PlotAnnotation(visible=true, x=xexperiment[6], y=yexperiment[6], text="possible outlier")]
)

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = [pd_line("Sinus", xrange), pd_scatter("Experiment", xexperiment, dx, yexperiment, dy)]
layout::R{PlotLayout} = pl()
config::R{PlotConfig} = PlotConfig()
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/scatter_polar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pd(name) = PlotData(
name = name,
)

@reactive mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = [pd("Random 1"), pd("Random 2")]
layout::R{PlotLayout} = PlotLayout(
polar = PlotLayoutPolar(radialaxis= RadialAxis(true, [0, 50])),
Expand Down
2 changes: 1 addition & 1 deletion StipplePlotly/subplots2x2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ layout = PlotLayout(
],
)

@reactive! mutable struct Model <: ReactiveModel
@vars Model begin
data::R{Vector{PlotData}} = plotdata, READONLY
layout::R{PlotLayout} = layout, READONLY
config::R{PlotConfig} = PlotConfig(), READONLY
Expand Down
2 changes: 1 addition & 1 deletion _broken_/MultiUserApp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const plot_options = OptDict(

const xx = Base.range(0, 4π, length=200) |> collect

@reactive mutable struct MyDashboard <: ReactiveModel
@vars MyDashboard begin
a::R{Float64} = 1.0
b::R{Float64} = 0.0
c::R{Float64} = 0.0
Expand Down
2 changes: 1 addition & 1 deletion _broken_/WebCam.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function start_camera() # restart camera
CAM_PROCESS[] = _start_camera()
end

@reactive! mutable struct WebCam <: ReactiveModel
@vars WebCam begin
cameraon::R{Bool} = true
imageurl::String = ""
cameratimer::Int = 0
Expand Down
2 changes: 1 addition & 1 deletion _broken_/WebCam2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ end
# emergency break:
# Base.throwto(cameraproc, InterruptException())

@reactive! mutable struct WebCam <: ReactiveModel
@vars WebCam begin
cameraon::R{Bool} = true
imageurl::String = ""
cameratimer::Int = 0
Expand Down
2 changes: 1 addition & 1 deletion _broken_/WebCam3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function stop_camera(camera::Camera)
end
end

@reactive! mutable struct WebCam <: ReactiveModel
@vars WebCam begin
camera::R{String} = CAMERAS[first(VideoIO.CAMERA_DEVICES)].camera
cameraon::R{Bool} = false
cameratimer::Int = 0
Expand Down