0.2.11 • Published 7 years ago

kea-rails-loader v0.2.11

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

kea-rails-loader

This is an experimental module. Do not use with anything serious.

Given a rails controller that includes Kea::Controller from kea-on-rails like this:

# at /app/scenes/search/result/controller.rb
class Scenes::Search::Result::Controller < ApplicationController
  include Kea::Controller

  def reputation
    @user = User.find(params[:id])

    render json: {
      id: @user.id,
      name: @user.full_name,
      reputation: @user.reputation
    }
  end
end

Import and use it through webpack like this:

// at /app/scenes/search/result/reputation.js
import controller from './controller.rb'

controller.reputation({ id: this.props.id }).then(response => {
  console.log(response.name)
})

In your webpack config:

{
  module: {
    loaders: [
      { test: /\.rb$/, loader: 'kea-rails-loader' }
    ]
  }
}

Optional arguments for loader with defaults: ?camelize=true&engine=$&endpoint=/_kea.json

camelize - should the function names be camelized? endpoint.add_favourite() gets turned into endpoint.addFavourite()

engine - what to use to do the request. Currently only $ and jQuery are supported. $ is the default. The engine must be globally exposed to the loader.

endpoint - where does the kea-on-rails counterpart live?

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago