2.8 Refresh view (after BMesh.to_mesh)

Here I am replacing the default cube. Problem is viewport don’t refresh after. What would be the proper way to refresh view?

import bpy
import bmesh

bm = bmesh.new()
bmesh.ops.create_cube(bm, size=5.0)
mesh = bpy.data.meshes['Cube']
bm.to_mesh(mesh)

I have tried update like this, but it’s not helping:

bpy.context.view_layer.update()
bpy.context.evaluated_depsgraph_get().update()

I am writing similar import addon that does mostly replacing mesh data, and I do have the same problem with it.

mesh.update()

To refresh a view you have to tag the area for update.

context.area.tag_update()

Thank you. This works fine.