Skip to main content

Refresh

Simple refresh

To refresh the list of stories call refresh() from StoryView. For example, if you need to implement the "Pull to refresh" functionality.

The data for the list corresponding to the current user session and the list of tags will be re-requested when calling refresh() .

Related articles

New v1.22.1 signature allows to pass new feed and tags to the refresh() method. Usage examples are listed here:

ViewController.swift

...
var storyView: StoryView!

override func viewDidLoad() {
super.viewDidLoad()
//initialize StoryView
storyView = StoryView(frame: CGRect(x: 0.0, y: 100.0, width: 320.0, height: 160.0))
//add object to the view
view.addSubview(storyView)

//running internal logic
storyView.create()
}

// handling a refresh event, e.g. from a button or PullToRefresh
func refresh() {
// refresh StoryView
storyView.refresh()
}
...

Refresh with feed and tags update

Before v1.22.1 it was possible to update the feed list to a new feed only by recreating StoryView.

In v1.22.1, newFeed: <String?> = nil and newTags: <Array<String>?> = nil parameters were added to the refresh() method to refresh stories feed and tags.

To update the stories feed list you need to specify the name of the feed you want to update to.

You can also update the list of tags for the feed.

ViewController.swift

...
var storyView: StoryView!

override func viewDidLoad() {
super.viewDidLoad()
//initialize StoryView
storyView = StoryView(frame: CGRect(x: 0.0, y: 100.0, width: 320.0, height: 160.0))
//add object to the view
view.addSubview(storyView)

//running internal logic
storyView.create()
}

// receiving an event to change the feed in the list of stories
func refresh(feed: String) {
// StoryView refresh with change of feed name
storyView.refresh(newFeed: feed)
}

// receiving an event to change the feed and tag list in the list of stories
func refresh(feed: String, tags: Array<String>) {
// StoryView refresh with change of feed name and tags list
storyView.refresh(newFeed: feed, newTags: tags)
}
...
tip
  1. If you leave the parameters unset or pass nil the list will be updated as usual.
  2. The new tag list works the same way as the setTags(<Array<String>>) method in InAppStory class. In this case, all set tags before refresh will be overwritten.