Giter Site home page Giter Site logo

stream-example-parse's Introduction

GetStream.io, Parse cloud code & EmberJS

Warning

Support for Parse has been discontinued. Some of this integration might still work, but you're on your own as it's no longer supported.

###Activity Streams & Newsfeeds

This example app helps you create activity streams & newsfeeds with Parse Cloud Code and GetStream.io.

What you can build:

  • Activity streams such as seen on Github
  • A twitter style newsfeed
  • A feed like instagram/ pinterest
  • Facebook style newsfeeds
  • A notification system

Demo

You should start by checking out the demo hosted on Parse.

About Parse Cloud & GetStream.io

Parse Cloud allows you to write server side application logic and extend the functionality of your existing Parse installation. GetStream.io allows you to build scalable newsfeeds and activity streams. This example app shows how you can get them to work together.

The example app is based on EmberJS and showcases a Twitter/Facebook style community.

Tutorial

Installing the Stream library

The Parse cloud compatible client can be found in cloud/getstream.js. The documentation for the client can be found on getstream.io/docs If you haven't tried out getstream.io before I recommend the getting started. The interactive API tutorial will get you up to speed in a few minutes.

Syncing activities to getstream.io

To build your activity stream you need to notifity getstream.io of 2 things:

  1. When activities are added/removed
  2. When follow relationships change

The code to notify GetStream.io of these events can be found in cloud/main.js For each model defined in settings.activityModels we'll listen to the Parse.Cloud.afterSave and Parse.Cloud.afterDelete methods.

Furthermore we also listen to the changes in settings.followModel and sync the changes.

Creating activities

Now that our Parse Cloud code is correctly setup, activities created via Parse will get published to getstream.io

// create a new tweet
var tweet = new Tweet();
// we write to the user feed
tweet.set('feedSlug', 'user');
tweet.set('feedUserId', user.id);
// the tweet's data
tweet.set('actor', user);
tweet.set('verb', 'tweet');
tweet.set('tweet', 'hello world');
tweet.set('likes', 0);
tweet.save();

When you call tweet.save() the Parse object is created. After the tweet is created the Parse.Cloud.afterSave trigger will publish the activity to getstream.io.

Reading feeds

You can read feeds by using a Parse.Cloud.run('feed') call, for example:

var promise = Parse.Cloud.run('feed', {
	feed : 'user:1'
});

Will retrieve the user feed for user 1.

Advanced: Running this example app

Settings

If you want to install this example app on your own parse instance you'll need to update a few setting files

  1. signup for parse, getstream.io and create a github app (for the github login)
  2. edit cloud/settings.js
  3. edit config/global.json
  4. edit public/index.html (the inline config variable)

Dev tools

  1. install gulp, compass and bower
  2. bower install
  3. gulp
  4. parse develop

gulp will monitor for changes and livereload the index.html file parse develop will upload your cloud code and host it at .parseapp.com.

stream-example-parse's People

Contributors

tbarbugli avatar thijsgoos avatar tschellenbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stream-example-parse's Issues

mark_seen and mark_read arrays imitating `true` behavior

I’m trying to use mark_read and mark_seen options on feed.get() with arrays of activity IDs. I’m getting the IDs from my aggregated notifications feed. It seems that whenever I make the call while passing the IDs, it is still just treating the call the same as if I had passed true. Here are the options going into the feed.get() call:

{  
   "id_lte":"936b4780-b575-11e4-a957-0a13a3a489d2",
   "id_gte":"cd31d970-b543-11e4-a0f7-0ae3a1a36207",
   "mark_read":[  
      "936b4780-b575-11e4-a957-0a13a3a489d2",
      "332cf400-b551-11e4-9bd7-0ae3a1a36207",
      "cd31d970-b543-11e4-a0f7-0ae3a1a36207"
   ],
   "mark_seen":[  
      "936b4780-b575-11e4-a957-0a13a3a489d2",
      "332cf400-b551-11e4-9bd7-0ae3a1a36207",
      "cd31d970-b543-11e4-a0f7-0ae3a1a36207"
   ]
}

I expect it to only mark certain items as read, but it’s marking all items as read. The server responds saying I have 0 unread and unseen items. However I expect the items I have left out of the arrays to remain unread and unseen.

I am not sure if this is a client or an endpoint issue

failed to query the data needed for enrichment

I run the code:

Parse.Cloud.run("feed", {feed: "user:dcyRc65vUR:",limit:3 })

I have not altered the cloud "feed" function. This is the full error message from the Parse Logs
E2015-11-06T17:23:41.402Z]v10 Ran cloud function feed for user dcyRc65vUR with:
Input: {"feed":"user:dcyRc65vUR:","limit":3}
Result: success/error was not called
I2015-11-06T17:23:41.757Z]failed to query the data needed for enrichment

I've tried to troubleshoot, but no luck. Some help would be awesome!

got error when run cloud function 'feed'

E2015-02-27T08:10:26.094Z]v652 Ran cloud function feed with:
Input: {"feed":"user:IXb7HGtnc2","id_lte":0,"limit":3}
Result: ReferenceError: setTimeout is not defined
at nextTick (getstream.js:17488:9)
at onwrite (getstream.js:18970:7)
at WritableState.onwrite (getstream.js:18804:5)
at afterTransform (getstream.js:18585:5)
at TransformState.afterTransform (getstream.js:18560:12)
at Hash._transform (getstream.js:10676:3)
at Hash.Transform._read (getstream.js:18665:10)
at Hash.Transform._write (getstream.js:18653:12)
at doWrite (getstream.js:18931:10)
at writeOrBuffer (getstream.js:18921:5)

clound function 'feed':
/*

  • View to retrieve the feed, expects feed in the format user:1
  • Accepts params
    *
  • feed: the feed id in the format user:1
  • limit: how many activities to get
  • id_lte: filter by activity id less than or equal to (for pagination)
    *
    */
    Parse.Cloud.define("feed", function(request, response) {
    var feedIdentifier = request.params.feed;
    var feedParts = feedIdentifier.split(':');
    var feedSlug = feedParts[0];
    var userId = feedParts[1];
    var id_lte = request.params.id_lte || undefined;
    var limit = request.params.limit || 100;
    var params = {
    limit : limit
    };
    if (id_lte) {
    params.id_lte = limit;
    }
    // initialize the feed class
    var feed = client.feed(feedSlug, userId);
    feed.get(params, function(httpResponse) {
    var activities = httpResponse.data;
    // enrich the response with the database values where needed
    var promise = utils.enrich(activities.results);
    promise.then(function(activities) {
    response.success({
    activities : activities,
    feed : feedIdentifier,
    token : feed.token
    });
    });
    }, utils.createHandler(response));
    });

please help me find out what's wrong.

Still there?

Is this repo still updated or don't you support it anymore ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.