DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
      • types
        • SocketEventListener
      • properties
        • Server
          • prototype
            • emit
            • on
            • onFeathersService
            • restore
        • requestHandlerToListener
        • storeToListeners
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-fixture-socket
  • /
  • Server
  • /
  • onFeathersService
  • / On this page
    • onFeathersService

      function

      Subscribes to mocked server socket events to work as FeathersJS CRUD service.

      • source

      server.onFeathersService(name, fixtureStore, [options])

      Subscribes to mocked server socket events according to FeathersJS protocol. Uses fixture store [can-fixture.Store] as a resource storage.

      var fixtureStore = fixture.store([
        {id: 1, title: 'One'},
        {id: 2, title: 'Two'},
        {id: 3, title: 'Three'}
      ], new canSet.Algebra({}));
      
      server.onFeathersService("messages", fixtureStore})
      

      Parameters

      1. name {String}:

        The name of Feathers service.

      2. fixtureStore {Store()}:

        A fixture store. See store for more details.

      3. options {Object}:

        Options, e.g. property name for id.

      Use

      Instantiate fixture store by calling store and provide FeathersJS service name:

      var fixtureStore = fixture.store([
        {_id: 1, title: 'One'},
        {_id: 2, title: 'Two'},
        {_id: 3, title: 'Three'}
      ], new canSet.Algebra(canSet.props.id('_id')));
       *
      mockServer.onFeathersService('messages', fixtureStore, {id: "_id"});
      

      This will emulate FeathersJS server CRUD service.

      Now from Feathers client app you can do:

      // Import dependencies:
      var io = require("socket.io-client");
      var feathers = require('feathers/client');
      var feathersSocketio = require('feathers-socketio/client');
      var hooks = require('feathers-hooks');
      
      // Configure Feathers client app:
      var socket = io("http://api.my-feathers-server.com");
      var app = feathers()
        .configure(hooks())
        .configure(feathersSocketio(socket));
      
      // Create client Feathers service:
      var messagesService = app.service('messages');
      
      // Test:
      messagesService.get(1).then(function(data){
        assert.deepEqual(data, {id: 1, title: 'One'}, 'get should receive an item');
      });
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.