riptide v0.5.0-beta7 Riptide View Source

Riptide is a data first framework for building realtime applications. Riptide makes building snappy, realtime applications a breeze by letting you think purely in terms of your data and functionally about what should happen when it changes.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Convience method to apply a mutation that deletes a single path

The same as delete/2 but raises an exception if it fails

Convience method to apply a mutation that merges a single value

The same as merge/3 but raises an exception if it fails

Apply a mutation. This will do following steps in order

The same as mutation/2 but raises an exception if it fails

Pass in a query and get the results.

The same as query_path/3 but raises an exception if it fails

Starts a Riptide process.

Return a stream of values underneath a path

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete(path, state \\ %{internal: true})

View Source

Convience method to apply a mutation that deletes a single path

Examples

iex> Riptide.delete(["foo", "bar"])
{:ok, %{
  delete: %{
    "foo" => %{
      "bar" => 1
    }
  },
  delete: %{}
}}
Link to this function

delete!(path, state \\ %{internal: true})

View Source

The same as delete/2 but raises an exception if it fails

Link to this function

merge(path, value, state \\ %{internal: true})

View Source

Convience method to apply a mutation that merges a single value

Examples

iex> Riptide.merge(["foo", "bar"], "hello")
{:ok, %{
  merge: %{
    "foo" => %{
      "bar" => "hello
    }
  },
  delete: %{}
}}
Link to this function

merge!(path, value, state \\ %{internal: true})

View Source

The same as merge/3 but raises an exception if it fails

Link to this function

mutation(mut, state \\ %{internal: true})

View Source
mutation(Riptide.Mutation.t(), any()) ::
  {:ok, Riptide.Mutation.t()} | {:error, any()}

Apply a mutation. This will do following steps in order

  1. Trigger Riptide.Interceptor.mutation_before/4
  2. Trigger Riptide.Interceptor.mutation_effect/4
  3. Broadcast mutation to interested processes
  4. Write mutation to stores
  5. Trigger Riptide.Interceptor.mutation_after/4

Examples

iex> mut = Riptide.Mutation.put_merge(["foo", "bar"], "hello")
iex> Riptide.mutation(mut)
{:ok, %{
  merge: %{
    "foo" => %{
      "bar" => "hello
    }
  },
  delete: %{}
}}
Link to this function

mutation!(mut, state \\ %{internal: true})

View Source

The same as mutation/2 but raises an exception if it fails

Link to this function

query(query, state \\ %{internal: true})

View Source

Pass in a query and get the results.

Read more about query structure here. State parameter is optional and is passed to interceptors.

Options

  • :min - Starting range of query, optional
  • :max - End range of query, optional
  • :limit - Max number of results, optional

Examples

iex> Riptide.query(%{ "todo:info" => %{} })
%{
  "todo:info" => %{
    "todo1" => %{
      "text" => "Document riptide"
    }
  }
}
Link to this function

query_path(path, opts \\ %{}, state \\ %{internal: true})

View Source

Return data under a specific path

Options

  • :min - Starting range of query, optional
  • :max - End range of query, optional
  • :limit - Max number of results, optional
Link to this function

query_path!(path, opts \\ %{}, state \\ %{internal: true})

View Source

The same as query_path/3 but raises an exception if it fails

Starts a Riptide process.

Probably should not called this directly and instead should be placed inside your application's root supervisor.

Options

  • :port - Optional, will override default port of 12_000
Link to this function

stream(path, opts \\ %{}, state \\ %{internal: true})

View Source

Return a stream of values underneath a path

Options

  • :min - Starting range of query, optional
  • :max - End range of query, optional
  • :limit - Max number of results, optional

Examples

iex> Riptide.stream(["todo:info"]) |> Enum.take(1)
[
  %{"todo1", %{ "text" => "Document riptide" }}
]